[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to detect bash?

From: mwoehlke
Subject: Re: How to detect bash?
Date: Wed, 11 Oct 2006 10:13:10 -0500
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv: Gecko/20060909 Thunderbird/ Mnenhy/

Stephane Chazelas wrote:
On Tue, Oct 10, 2006 at 06:14:22PM -0500, mwoehlke wrote:
$ 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
Eh? I get:

$ zsh -c 'echo "`/dev/null 2>&1`"' bash
zsh:1: permission denied: /dev/null

Well, I do get what I said with zsh 4.3.2

$ ARGV0=bash ash -c 'echo "`/dev/null 2>&1`"; echo $BASH'
/dev/null: permission denied

(note that this command must be run from zsh which uses
ARGV0=... to set ash's argv[0]).

You must have an older /ash/ than I have mine is one of the
OpenBSD based sh ones (found on debian).

Maybe, I never use ash or zsh (intentionally, anyway; IIRC Cygwin uses ash under the covers some time, but I never use either interactively), so I just got whatever versions came with the system (FC4). I don't doubt that you can make these work, I'm just noting that ability/method of circumventing the aforementioned test is inconsistent. :-)

So neither of your counter-examples is working for me (although both look like they *should*; go figure).

Though I'd bet the third one with .zshenv worked.

But since you didn't counter BASH_SUBSHELL (and since I'm too lazy to change it now) I guess I'll stick with that. :-)

BASH_SUBSHELL is a relatively recent addition to bash. Most
systems still don't have a bash3.

$ bash -c 'echo "$BASH_VERSION, <$BASH_SUBSHELL>"'
2.05b.0(2)-release, <>

Ah, well, I have 3.1.17 builds available for 9 of 10 systems these scripts may need to run on (plus two others) and the tenth has 3.1.0. I'm not particularly concerned if I'm only catching 3.0+ versions, since that will also insulate me from anything else that is 3.0+-specific (i.e. it's OK if I use new features because I've ensured that I have them). Thanks for pointing this out, though.

Will your shell have salvation? Only if it's Bourne Again.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]