On Fri, 26 Nov 2010 10:11:07 -0500 (EST), Joao Ferreira wrote: > > considering sh, bash and csh, can I somehow, inside a script, determine > if I'm being run with any of these 3 shells... > > I need to determine wich interpreter is running me...
The login shell is set in /etc/passwd on a user-by-user basis. For example, consider this entry: steve:x:1000:1000:Stephen Powell,,,:/home/steve:/bin/bash This shows that when user "steve" logs in, his login shell will be bash. For a shell script, the script itself can force a particular shell to be used by a special comment in line 1: #!/bin/bash in line 1 will force bash to be used. What most shell scripts do is put #!/bin/sh in line 1, and this causes the default shell on the system to be used. The default shell can be determined by ls -Al /bin/sh For example, on my system the output is lrwxrwxrwx 1 root root 4 Nov 13 11:20 /bin/sh -> dash which indicates that the default shell for scripts on my system is dash. If a script wants to know which shell is running it, the variable $0 might work. For example, echo $0 might produce -bash If there is a leading hyphen, it is the login shell; otherwise it is not the login shell. A shell script should never see a leading hyphen. -- .''`. Stephen Powell : :' : `. `'` `- -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/827876752.656424.1290788853280.javamail.r...@md01.wow.synacor.com