- Mar 2, 2005
- 799
- 0
- 0
So at my job we use tcsh, and "the way it's always been done" is that if you need to string a few commands together, you just write a c shell script (#!/bin/csh, which is just an alias to tcsh).
Lately I've realized (for myself, not just cos someone told me) the superiority of bash for scripting, and, frankly, interactive shell as well. Anyway what I've been doing is every time I have to modify a c shell script, I change it to #!/bin/sh, which is just an alias to bash.
I'm used to having all the stuff I set in my .cshrc file, including aliases, available in my scripts, so I was quite consternated when I tried to use the distill command, which I have aliased to a Perl script I wrote that uses ps2pdf. Apparently our version of ps2pdf isn't smart enough to do glob expansions.
Anyway when I converted this script it obviously broke. So I have to
a) make sure to use #!/bin/bash--not #!/bin/sh
b) shopt -s expand_aliases in ~/.bashrc
c) setenv BASH_ENV ~/.bashrc in my .cshrc file*
What a pain! Why WOULDN'T I want my aliases available when I code a script?
The only explanation I saw was here.
"In a script, aliases have very limited usefulness."
Why???
*It seems that one could also do something equivalent with a ~/.bash_profile but why create a new file when I cna just add a line to ~/.cshrc?
TIA
Lately I've realized (for myself, not just cos someone told me) the superiority of bash for scripting, and, frankly, interactive shell as well. Anyway what I've been doing is every time I have to modify a c shell script, I change it to #!/bin/sh, which is just an alias to bash.
I'm used to having all the stuff I set in my .cshrc file, including aliases, available in my scripts, so I was quite consternated when I tried to use the distill command, which I have aliased to a Perl script I wrote that uses ps2pdf. Apparently our version of ps2pdf isn't smart enough to do glob expansions.
Anyway when I converted this script it obviously broke. So I have to
a) make sure to use #!/bin/bash--not #!/bin/sh
b) shopt -s expand_aliases in ~/.bashrc
c) setenv BASH_ENV ~/.bashrc in my .cshrc file*
What a pain! Why WOULDN'T I want my aliases available when I code a script?
The only explanation I saw was here.
"In a script, aliases have very limited usefulness."
Why???
*It seems that one could also do something equivalent with a ~/.bash_profile but why create a new file when I cna just add a line to ~/.cshrc?
TIA