2

I want to execute some scripts on dash shell compared to standard default bash. This is an example (test.sh)

#!/bin/dash
echo $SHELL 
echo $0

This execution gives me

/bin/bash
./test.sh

as output. I was expecting '/bin/dash' as output.

If this is wrong, can someone let me know how do I actually work on dash. Thanks

marc
  • 949
  • 14
  • 33

3 Answers3

3

SHELL environment variable picks up the value from /etc/passwd. (It denotes the path to user's preferred command language interpreter.)

This value wouldn't change if you change the shell in your session or your script.

devnull
  • 118,548
  • 33
  • 236
  • 227
1

You can validate that you are running dash by adding the command

ps | grep $$

The $$ variable contains the PID of the process of the running shell.

user000001
  • 32,226
  • 12
  • 81
  • 108
  • This worked: dash test.sh with the above command and obtained 'dash' at output confirming the shell. – marc Aug 14 '13 at 09:20
1

This one would show the exact command.

ps o command --no-header --pid "$$"
konsolebox
  • 72,135
  • 12
  • 99
  • 105