Computer Forums

Search Tech-Forums.net

Member Login

Remember Me? Sign Up! | Forgot Password
 
 
Reply
Old 11-29-2003, 10:33 PM   #1 (permalink)
 
Newb Techie
Join Date: Nov 2003
Posts: 1
rsmith6
Default simple shell

i am in the process of creating a simple shell written in c and used in unix. i have covered all my basis including pipes, redirection. etc. but i am having difficulty with environmental variables and variable substitution. the assignment requests:

builtin functions:
set [ <name> <value> ]
unset <name>
setenv [ <name> <value> ]
unsetenv <name>

getshv(<name>) that acts like getenv(3c)
putshv(<name>,<value>) that acts like putenv(3c)
and use an external shvar that acts like environ
char *shvar[];
with up to 1024 shell variables, as determined by:
#define NSHVAR 1024

variable sub:
Only ${<name>} or ${<digit>} required

You can, if you wish, do $PATH or $1 also.

Substitution can be anywhere in a command line including a whole line:

set mycmd “ls –l *.c”



è ${mycmd}



$(digit) positional parameters like $0 $1 $2 ...

These are the arguments passed to your shell program from the argv[] array.

mysh -f a b c

-> echo ${0}

mysh

-> echo ${1}

-f

-> echo ${2}

a

-> echo ${#}

5


any help that anyone could give me in coding this would be appreciated. thanks
rsmith6 is offline   Reply With Quote
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On