Possible Duplicate:
How to test what shell I am using in a terminal?

For example the following script

#!/bin/bash

issue_interpreter_name

would issue:

bash
link|improve this question
yes, thank you for pointing me there – Ingo May 3 at 10:06
@jw013 more or less the same question but jippie's answer is better then the ones in the linked question :-) – Matteo May 3 at 18:52
feedback

closed as exact duplicate by sr_, Stéphane Gimenez, Kevin, Gilles, Mat May 4 at 10:23

This question covers exactly the same ground as earlier questions on this topic; its answers may be merged with another identical question. See the FAQ for guidance on how to improve it.

2 Answers

#!/bin/sh  
ps h -p $$ -o args='' | cut -f1 -d' '
  • ps process list
  • h 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 information
  • cut cut the output into parts
  • -f1 print only the first field
  • -d' ' use a space as a field separator

    $ ./testje

    /bin/sh

link|improve this answer
On Mac OX X I get an additional line with the header ARGS. With -o args='' you can remove the header – Matteo May 3 at 18:50
1  
Verified Matteo's comment on Linux (ubuntu 12.04) and works as designed. Updated my answer. – jippie May 3 at 18:55
feedback

If it's a local user, the 7th field of /etc/passwd is their shell. Are you looking for the currently preferred shell?

link|improve this answer
1  
-1 The default login shell is not necessrily the one currently running. – rahmu May 3 at 12:05
feedback

Not the answer you're looking for? Browse other questions tagged or ask your own question.