Possible Duplicate:
How to test what shell I am using in a terminal?
I want to detect which interpreter a shell script is using. For example the following script:
#!/bin/bash
issue_interpreter_name()
Should reveal the interpreter:
bash
Possible Duplicate:
How to test what shell I am using in a terminal?
I want to detect which interpreter a shell script is using. For example the following script:
#!/bin/bash
issue_interpreter_name()
Should reveal the interpreter:
bash
#!/bin/sh
ps h -p $$ -o args='' | cut -f1 -d' '
ps process listh do not print column headers-p <PID> list only process id PID$$ replaced by the shell with current PID-o args print the command line, no other informationcut cut the output into parts-f1 print only the first field-d' ' use a space as a field separator
$ ./testje
/bin/sh
ARGS. With -o args='' you can remove the header
– Matteo
May 03 '12 at 18:50
If it's a local user, the 7th field of /etc/passwd is their shell. Are you looking for the currently preferred shell?