Re: Shells in X11/terminal
Re: Shells in X11/terminal
- Subject: Re: Shells in X11/terminal
- From: Tim Cutts <email@hidden>
- Date: Thu, 18 Nov 2004 09:32:47 +0000
On 17 Nov 2004, at 10:46 pm, Stephen Fortus Signer wrote:
Hesitate to ask but is the change in the shell line to
/bin/tcsh
Had been frustrated as a number of beginner books assume a C derived
shell
and had been working in bash shell; did not know if all the commands
worked
ie. could not get make in the bash shell
Whether a "command" works in a given shell rather depends on whether
the command in question is a program on the system (in which case it
will) or whether it's a shell builtin, or some other part of the
shell's compound statement syntax (in which case it won't because tcsh
and bash are very different in this regard).
So, for example, a simple command like:
make
or even pipes like
ls -l | awk '{s+=$5} END {print s}'
should work fine, because make, ls and awk are all separate programs,
and the syntax for pipes is the same in both shells.
But the syntax for manipulating variables is quite different:
(t)csh: set foo=bar (ba)sh: foo=bar
(t)csh: setenv FOO bar (ba)sh: FOO=bar; export FOO
Note this is one place bash is friendlier - the syntax for shell
variables and environment variables is basically the same (you just
have to export the environment version). csh's syntaxes are annoyingly
different.
Anything involving more program-like syntax, such as loops and
conditionals, tends to be quite different between the two shells. A
conditional:
(t)csh:
if ( -x /usr/local/bin/foo ) then
/usr/local/bin/foo
endif
(ba)sh:
if [ -x /usr/local/bin/foo ]; then
/usr/local/bin/foo
fi
In interactive use, both shells offer similar levels of functionality.
However, if you start wanting to do more complex things with the
command line, I thoroughly recommend using bash. Most system shell
scripts are traditionally written using the bourne shell (i.e. bash)
syntax, not (t)csh, and there are good reasons for this
(http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/).
If you're going to use command line UNIX extensively you will have to
learn bourne shell scripting eventually anyway, so you might as well
use a bourne-compatible shell such as bash for your interactive shell,
and then you only need to learn one syntax, not two.
Tim
--
Dr Tim Cutts
Informatics Systems Group, Wellcome Trust Sanger Institute
GPG: 1024D/E3134233 FE3D 6C73 BBD6 726A A3F5 860B 3CDD 3F56 E313 4233
_______________________________________________
Do not post admin requests to the list. They will be ignored.
X11-users mailing list (email@hidden)
This email sent to email@hidden