[Top][All Lists]

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

Re: How to detect bash?

From: Bob Proulx
Subject: Re: How to detect bash?
Date: Tue, 10 Oct 2006 22:27:21 -0600
User-agent: Mutt/1.5.9i

mwoehlke wrote:
> Anyone have any clever, VERY reliable tricks for detecting if the
> current shell is bash? The obvious way is '[ -n "$BASH" ]', but in the

I would probably avoid the clever and go with the simple to understand
and unlikely to be accidentally invoked method.

  test ${BASH_VERSION+set} = set && echo yes || echo no

Sure someone could work around it but they are unlikely to do so.  And
if they want to work around it as has been noted then they could
always edit the script.

And I agree with you that pattern matching against $SHELL does not
work.  It is often not the shell that is currently running.

  SHELL=/bin/csh bash -c 'printenv SHELL'

> >And why the heck do you think this is is *bug* in *bash*?
> Um, did I say I did? I didn't see a not-bugs list, and I'm not the first 
> one to ask a 'How do I...' question here.

Your question was specific to bash and so I think it is perfectly good
and on topic here.  I specifically mention because I called another
poster about that just recently.


reply via email to

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