This tip is incredibly obvious, yet sometimes people don't think to do
it.
A shell is just a program - like ls, vim, man, gcc or all the other
residents of bin/ directories. If you want to try a new one, just run
it.
There are two main reasons to try a different shell than the one
you're running. First, you're considering switching to a new shell.
All the kewl kidz are using foosh and you don't want to be left out.
Alternatively you use something other than bash (or sh) and need to make
sure your shell-fu is correct for a shell script you're writing.
Shells, like any unix program, inherit their environment. But that can
cause problems. My prompt in zsh is controlled by the environment var
PS1 - which is what bash uses too. The difference being that they use
completely different escapes. So it's best to clean your environment -
luckily there's the env command.
To get something close to what it would be like to login with a new
shell, use the env command:
env -i bash -l
Most shells interpret -l to mean login shell.
This can also work for trying out shell constructs - but you won't have
access to your shell's history. For that you can just prefix with bash
-c and wrap it in quotes:
bash -c 'for f in $(seq 1 5); do echo $f; done'
Obviously your shell's quoting rules apply. For anything complex it's
best to just make a small shell script.
Kevin
--
Kevin Lyda US Citizen Abroad? Had Enough? Register
kevin at ie.suberic.net **** to vote: www.VoteFromAbroad.org ****
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!