Page 1 of 1

custom UNIX shell

Posted: Tue Oct 20, 2009 8:13 pm
by spt60
Hi I'm learning about UNIX shell using Ubuntu 9.04. I'm wondering how a "cd <directory>", "dir <directory>" and "printenv" in bash shell work and try to replicate it.

It doesn't have to be as complex but I wonder how to code it. Basically when running my own shell program such as "ishell cd <directory>" it will change the current default directory to <directory> and also change the PWD environment variable; and "ishell dir <directory>" will list the content of the directory; "ishell env" will list all the environment strings.

Thanks! :wink:

Re: custom UNIX shell

Posted: Sun Oct 25, 2009 1:37 am
by Temetka
How much shell scripting experience do you have and also how many years of experience do you have as a programmer / linux admin in general?

New shells are hard to code.

You could create your own scripts, rename to the original commands and have the original commands renamed then called from the script. That is a very circular, and pointless method do use your ishell command, but it would work.

To what purpose are you trying to accomplish with this.

Re: custom UNIX shell

Posted: Sun Oct 25, 2009 8:18 am
by Volker
Oh boy :Nice:

The shell uses the posix C api to list directories and set environment variables. For example, directory listing is done with http://en.wikipedia.org/wiki/Dirent.h.

Re: custom UNIX shell

Posted: Sat Oct 31, 2009 10:55 am
by spt60
Volker wrote:Oh boy :Nice:

The shell uses the posix C api to list directories and set environment variables. For example, directory listing is done with http://en.wikipedia.org/wiki/Dirent.h.
Thanks for your input. This should do the trick. If not I'll be back bugging you :D