Hi Andrew,

There seem to be quite a lot of resources on the web for shell.  Shell
is a programming language with conditionals and loops; you could for
instance write a webserver in it if you really wanted to.
You could start with
http://tldp.org/LDP/Bash-Beginners-Guide/html/index.html which looks
quite good.

Worth checking out the original classic book "The Unix Programming
Environment" - if you ever see it.  It's quite expensive but gives you
an idea of unix and the shell and how it all came about.

On 01/10/06, Andrew Dunkin <[EMAIL PROTECTED]> wrote:
If you have time, could you possibly explain what the change to
/etc/bashrc/ that you suggested did and why it fixed the problem.

The original line said PATH=<stuff>.
We changed it to PATH=$PATH:<stuff>.
By including $PATH, we preserve what was already in PATH before this
line is executed by the shell.  Failing to preserve what was in PATH
prior to the execution in this line is what caused you a problem.
The line is badly written.  The line inside java.sh is relatively
well-written.

(You have to append a variable name with '$' when used on the RHS of
the above example; this tells the shell to insert the value of PATH
into the RHS; similarly you say "echo $PATH" to view the value of
PATH)

You made a comment earlier in this exchange of emails as follows;
"It still wouldn't do what you wanted because it would be setting the
PATH variable of a subshell running off the shell you logged in to and
NOT the shell you are typing into."
This made little sense to me as I do not understand how shells and
subshells work.

That was badly worded.

Could you briefly explain what your comment meant. Even if I don't
understand your response, it will guide me in further research.

To start with, you have shell.  This allows you to interact with the
linux system (the kernel)  to run commands and access files etc.

The shell has at least 2 major modes - interactive and "batch-file" mode.

When you login to the command line, you are using bash interactively.
It displays a prompt and you type names of programs in it, hit return
and  it then gets the system to execute.  eg "ls" to list directory
contents.  So the shell mediates between you and the os.

You can also write shell scripts like your java.sh and store these in
files on your system.
To execute these, you have to invoke another shell and you do this
from your existing interactive shell
eg  % bash java.sh
'bash' is a new shell; it's a new, separate instance of the same
program as the interactive shell you logged in to; because you are
running it from your shell, it is referred to as a subshell.  It is
not interactive because it has been given 'java.sh' to execute.  It
will execute this and return its status to the interactive shell.

That is why 'bash java.sh' or 'sh java.sh' does not work as intended.
It only modifies the the subshell executing java.sh.

The use of 'export' in java.sh is significant; it puts the shell
variable into the execution environments for processes which are
executed by the shell executing java.sh.  In the case of 'bash
java.sh', 'export' is only working with respect to the subshell and
any processes it executes not your interactive shell.

When you're reading up on this be aware of environment variables vs
shell variables (use of 'export' , 'set' , 'printenv' , 'env'';
subshells vs using '.'; special shell variables like PATH etc

cheers,
Daniel.
--
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html

Reply via email to