|Subject:||Re: definite way to determine the running shell|
|Date:||Fri, 27 Mar 2015 12:52:45 +0800|
There are a lot of articles on the web about detecting the actually
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 (which
IMHO would be much better, and more like $TERM).
Now I see basically two other ways to detect a shell:
a) using ps or something similar... which is not really portable either
and can be rather easily/accidentally fooled
b) Using some env vars typically to the shell, e.g. BASH_VERSION for
AFAIU per default these are not declared'ed -x , so when I rund fooShell
from bash it wouldn't be inherited.
But the user could still manually mark it exportable.
c) I've also thought about somehow using e.g. shopt, when it runs I
could be sure, it was bash. But for that in turn I'd need to make sure
whether it's a built-in command, which works in bash with the "builtin"
built in command ;) ... but not portably as in POSIX shell command
language (at least not that I'd know).
Is there some better way to do this (at least to detect bash)? E.g. some
VAR that bash sets and that it would neither take from its own
environment when being started nor that it would pass on to processes?
|[Prev in Thread]||Current Thread||[Next in Thread]|