Search code examples
bashshelldash-shell

How to change shell to dash from bash


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


Solution

  • 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.