Reputation
2,098
Top tag
Next privilege 2,500 Rep.
Create tag synonyms
Badges
3 16 37
Impact
~128k people reached

Aug
8
comment How do I *reliably* and *simply* get the current shell interpreter name?
Ideally I think I'd want the real shell—if that's what determines actual compatibility—but I'd be happy enough with the on-disk name of the executable. Do you have in mind cases of malicious tampering, or cases where (e.g.) calls to sh are really handled by bash? In the latter case I guess it depends on how well bash mimics sh: will it fail on things that sh would have failed on?
Aug
8
comment How do I *reliably* and *simply* get the current shell interpreter name?
@Gilles: not the path, just the name of the shell. (I didn't understand the second question.)
Aug
7
revised How do I *reliably* and *simply* get the current shell interpreter name?
deleted 269 characters in body
Aug
7
revised How do I *reliably* and *simply* get the current shell interpreter name?
added 439 characters in body
Aug
7
revised How do I *reliably* and *simply* get the current shell interpreter name?
added 45 characters in body
Aug
7
comment How do I *reliably* and *simply* get the current shell interpreter name?
@DarkHeart: actually that fails to, since the variable assignment wasn't the problem on csh/tcsh, it was this part: ps -p $$ -o args='' | cut -f1 -d' ', which returns -sh on csh, and -csh on tcsh.
Aug
7
revised How do I *reliably* and *simply* get the current shell interpreter name?
added 271 characters in body
Aug
7
awarded  Citizen Patrol
Aug
7
comment How do I *reliably* and *simply* get the current shell interpreter name?
Basile: in any source-able function, it will be much more maintainable if you can keep the source in one file, rather than repeating code across 5 files, or whatever. And if the differences between the shells can as much as possible be handled by other functions that your function depends on, then you can keep a sane code base. Simply re-writing everything several times is a recipe for maintenance nightmares. No one writes 5 versions of a web app just because there are browser differences.
Aug
7
comment How do I *reliably* and *simply* get the current shell interpreter name?
To read the entirely off-topic discussion on whether Python is a shell: see here
Aug
7
comment How do I *reliably* and *simply* get the current shell interpreter name?
with a small modification it will work in fish, but then only in fish, unfortunately: ps h -p %self -o args='' | cut -f1 -d' '. This creates a chicken and egg problem... you have to know you're in fish in order to execute the fish version of the code...
Aug
7
comment How do I *reliably* and *simply* get the current shell interpreter name?
This fails in csh and tcsh.
Aug
7
revised How do I *reliably* and *simply* get the current shell interpreter name?
added 14 characters in body
Aug
7
comment How to test what shell I am using in a terminal?
this gives me my current directory name; also, under csh and tcsh it gives me Ambiguous output redirect.
Aug
7
comment How do I *reliably* and *simply* get the current shell interpreter name?
I'm on OS X, and the man page lists -f as an available option, taking the format as an argument.
Aug
6
comment How do I *reliably* and *simply* get the current shell interpreter name?
it's giving me a blank line... but if I understand what you're attempting to do it's very clever
Aug
6
asked How do I *reliably* and *simply* get the current shell interpreter name?
Aug
5
comment How to turn off color with `ls`?
Of course this is a bit like killing a fly with a shotgun: you lose all other options you'd added to ls aliases, and you lose them for the whole session, instead of just a single command.
Aug
5
revised How to turn off color with `ls`?
clarify question
Jul
22
awarded  Famous Question