On Tue, Oct 10, 2006 at 05:12:07PM -0500, mwoehlke wrote: > Dave Rutherford wrote: > >On 10/10/06, mwoehlke <[EMAIL PROTECTED]> wrote: > >>Anyone have any clever, VERY reliable tricks for detecting if the > >>current shell is bash? > > > >Well, I don't know if it's clever, but how about: > > Oh, my... Where do I *start*? > > >$ if [ "${SHELL//*/bash}" = "bash" ]; then echo y; fi > > $ echo $SHELL > /bin/sh > $ echo $BASH > /bin/bash > $ foo > bash: foo: command not found > > There is *ABSOLUTELY* no guarantee that $SHELL correctly points to bash, > or that $SHELL is even remotely correct for that matter. This is /worse/ > than relying on $BASH. > > But it does bring up an interesting possibility: > [ "`/dev/null 2>&1`" = "bash: /dev/null: Permission denied" ] [...]
You quest looks a bit pointless to me. What prevents the user to edit a copy of your script to remove the check anyway? $ zsh -c 'echo "`/dev/null 2>&1`"' bash bash: /dev/null: Permission denied $ zsh $ ARGV0=bash ash -c 'echo "`/dev/null 2>&1`"; echo $BASH' bash: /dev/null: Permission denied $ echo '/dev/null(){echo "bash: /dev/null: Permission denied"}' \ > >> ~/.zshenv $ zsh -c 'echo "`/dev/null 2>&1`"' bash: /dev/null: Permission denied And whatever check you do can be worked around in a way or another. -- Stéphane _______________________________________________ Bug-bash mailing list Bug-bash@gnu.org http://lists.gnu.org/mailman/listinfo/bug-bash