definite way to determine the running shell

2015-03-26 Thread Christoph Anton Mitterer
Hey. There are a lot of articles on the web about detecting the actually running shell. Unfortunately, just relying on $SHELL doesn't really work since when I invoke e.g. csh from bash, it would be still $SHELL=bash and I guess I won't be able to convince all shell upstreams to overwrite $SHELL (w

Re: definite way to determine the running shell

2015-03-27 Thread Eduardo A . Bustamante López
Why would the user set BASH_VERSION in the environment? That sounds like asking for trouble! If you're against someone who actively tries to fool you into thinking you're in bash, then it'll be very hard. One way that I think would work is to: - try to unset BASHOPTS (did it work? then it's not

Re: definite way to determine the running shell

2015-03-27 Thread Andreas Schwab
Christoph Anton Mitterer writes: > There are a lot of articles on the web about detecting the actually > running shell. Why do you need to know that? Andreas. -- Andreas Schwab, sch...@linux-m68k.org GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for somethi

Re: definite way to determine the running shell

2015-03-27 Thread Clark Wang
On Fri, Mar 27, 2015 at 11:36 AM, Christoph Anton Mitterer < cales...@scientia.net> wrote: > Hey. > > There are a lot of articles on the web about detecting the actually > running shell. > Unfortunately, just relying on $SHELL doesn't really work since when I > invoke e.g. csh from bash, it would

Re: definite way to determine the running shell

2015-03-27 Thread Eric Blake
On 03/27/2015 01:56 AM, Andreas Schwab wrote: > Christoph Anton Mitterer writes: > >> There are a lot of articles on the web about detecting the actually >> running shell. > > Why do you need to know that? As the autoconf world has proven, it's better to test for features (will THIS action work

Re: definite way to determine the running shell

2015-03-27 Thread Christoph Anton Mitterer
On Fri, 2015-03-27 at 08:56 +0100, Andreas Schwab wrote: > Why do you need to know that? Well there are so many use cases... my particular one is, that many shells share config files (e.g. .profile) and for other cases (e.g. aliases definitions) it would be handy if one could set up a sourcable sc

Re: definite way to determine the running shell

2015-03-27 Thread Christoph Anton Mitterer
On Fri, 2015-03-27 at 08:13 -0600, Eric Blake wrote: > As the autoconf Autotools... not really the saviour of the world ;-) > world has proven, it's better to test for features Well, it's not that I'd have something against that per se, but: - keeping a complex test suite for many cases up-to-da

Re: definite way to determine the running shell

2015-03-27 Thread Greg Wooledge
On Fri, Mar 27, 2015 at 07:46:19PM +0100, Christoph Anton Mitterer wrote: > - keeping a complex test suite for many cases up-to-date is not so easy > - since .bashrc and friends are e.g. sourced everytime I start a new > xterm, I'd rather try to avoid having extensive tests there ... why are you

Re: definite way to determine the running shell

2015-03-27 Thread Christoph Anton Mitterer
On Fri, 2015-03-27 at 14:56 -0400, Greg Wooledge wrote: > ... why are you running test suites in your .bashrc?? As said, I'd find it nice to have one aliases file for all shells, and that would in turn then be sourced from either .profile or rather .bashrc... so while tests wouldn't run in .bashr

Re: definite way to determine the running shell

2015-03-27 Thread Greg Wooledge
On Fri, Mar 27, 2015 at 08:05:29PM +0100, Christoph Anton Mitterer wrote: > On Fri, 2015-03-27 at 14:56 -0400, Greg Wooledge wrote: > > ... why are you running test suites in your .bashrc?? > > As said, I'd find it nice to have one aliases file for all shells, and > that would in turn then be sou

Re: definite way to determine the running shell

2015-03-27 Thread Dan Douglas
I just test for version strings. e.g. BASH_VERSION. It isn't ideal or robust but gets the job done depending on your requirements. There is no generally great solution. There are scripts that make better guesses but there aren't any that are meant for use in a library or that do fine-grained featu

Re: definite way to determine the running shell

2015-03-27 Thread Christoph Anton Mitterer
On Fri, 2015-03-27 at 15:11 -0400, Greg Wooledge wrote: > OK, this is for some personal configuration management. Well it's rather for some 1000 institute workstations,... > Not as part of > a product you're deploying, etc. As such, presumably you are not trying > to trick yourself into breaki

Re: definite way to determine the running shell

2015-03-27 Thread Christoph Anton Mitterer
On Fri, 2015-03-27 at 01:44 -0600, Eduardo A. Bustamante López wrote: > Why would the user set BASH_VERSION in the environment? That sounds like > asking > for trouble! Murphy's law! :D > - try to unset BASHOPTS (did it work? then it's not bash) > - Now, store the value of BASHOPTS in a temp va

Re: definite way to determine the running shell

2015-03-27 Thread Dan Douglas
On Fri, Mar 27, 2015 at 2:37 PM, Christoph Anton Mitterer wrote: > On Fri, 2015-03-27 at 01:44 -0600, Eduardo A. Bustamante López wrote: >> Why would the user set BASH_VERSION in the environment? That sounds like >> asking >> for trouble! > Murphy's law! :D > >> - try to unset BASHOPTS (did it wo