tags:

views:

80

answers:

2

I am working on bash shell When I type echo $PATH on $ prompt I get the value of path environment variable as

/opt/bin:/usr/local/bin:/usr/bin:/bin:/usr/games

I am creating my own shell and I want to print the path environment variable when user enters echo $PATH. How do I do that?

A: 

$PATH is interpreted by the shell. If you are going to write a shell, figuring out if there are environment variables in the command line and replacing them with their value is part of your task.

fvu
A: 

$ variables are set by the shell - either on initialization of the shell or by a user (directly or indirectly).

So if you want your shell to have a variable containing a list of directories to search for executables, you need to set it. PATH is a very sensible name to stick with!

nfm