On Fri, Aug 28, 2009 at 12:16:31PM -0400, David Hummel wrote: > On Fri, Aug 28, 2009 at 10:08 AM, Derek Martin wr= ote: > > And in my_env_file, the user also has something like: > > > > vi=3D`which vi` >=20 > I'm not really sure why you would want to do this. Well, the answer depends on what you mean. I set ENV so that I always have things I set up available to me, even in a context where some configuration I don't control tells, say, xterm, not to use a login shell. As for why I might want to do the vi thing above, here's an exerpt =66rom my .bashrc file which should illustrate: # Figure out what to use for EDITOR which_vim=3D`hash vim 2>/dev/null; hash -t vim 2>/dev/null` which_xemacs=3D`hash xemacs 2>/dev/null; hash -t xemacs 2>/dev/null` which_emacs=3D`hash emacs 2>/dev/null; hash -t emacs 2>/dev/null` if [ -x $which_vim ]; then EDITOR=3Dvim elif [ -x "$which_xemacs" ]; then EDITOR=3Dxemacs elif [ -x "$which_emacs" ]; then EDITOR=3Demacs else EDITOR=3Dvi fi This block of code, or at least one that's extremely similar, has been in my .bashrc (or whatever) since about 1997. Note that since the debian debacle, I've changed this version of my .bashrc to use hash, instead of which. But this is less portable. As it happens, where I use this code above, only Linux is in use (not strictly true, but close enough for my purposes), and my shell is always Bash, so it doesn't matter. My environment has been ported around with me from job to job, and my login files are written such that, to the greatest extent possible, they can be used on any Unix system of any flavor. The "master copy" still uses which. Invariably I add localizations, but I usually try to do that in a separate file that gets sourced. > > Also note that if your or .bashrc has commands in it that produce > > output to your terminal, then very likely if you scp files to that > > machine, the scp will fail. >=20 > Not sure why you would do this either. As a sysadmin, I saw it all the time. Every other week someone would ask me why their scp was failing. That was the reason. It's actually quite normal for people to put stuff that generates output in their login files: one reason to do so is to set up your terminal properly. The tset command generates escape sequences that it sends to your terminal for that purpose; they're not visible to you, but they *are* output. The scp command doesn't like that. If you put them in =2Eprofile, no problem... those commands will only be run in the context of an interactive login shell. If you put them in .bashrc, they'll be run any time the system starts a shell on your behalf (that's not a shell script). That's why it's very useful to know what files are sourced when and in what context. Most casual users can't be bothered with the details (quite understandably), and often they get it wrong as a result. > Yes, because bash is POSIX-compliant. The only argument I can see for > not symlinking sh to bash is if you're concerned about script > execution performance, in which case you can just install dash (which > is lighter and faster with fewer dependencies) and symlink sh to that. Or because you're not on a Linux system, and it's not installed, and there are strict controls over what gets installed, and bash isn't on the list. ;-) Please do not forget that Linux is not the only Unix in the world... Or because you're not the sysadmin of the box you're working on, and the sysadmin likes ksh. Or whatever... there are potentially any number of reasons. Just because bash can run virtually anywhere, doesn't mean it does. :) > > Obviously, I disagree. :) =A0The better option IMO is to learn to write > > portable shell scripts, and use /bin/sh. >=20 > If you've written what you believe to be a portable script using > /bin/sh, there's very little chance that it will not "just work" on a > system that symlinks sh to bash. That is exactly my point. In contrast, if you write a script that you believe is proper bash syntax, and were not mindful that you write portable scripts, there's a good chance that it will *not* execute on a system where sh is not bash. --=20 Derek D. Martin http://www.pizzashack.org/ GPG Key ID: 0xDFBEAD02 -=3D-=3D-=3D-=3D- This message is posted from an invalid address. Replying to it will result= in undeliverable mail due to spam prevention. Sorry for the inconvenience.