On my Linux box,
echo $SHELL results in
/bin/csh. So I assume my default shell is c-shell. I am trying to understand the behavior of a shell script.
scenario 1 - script contains -
echo $1 $2 $3 echo $* echo $argv $argv $argv echo $argv[*] echo $#argv
arg1 arg2 arg3 arg1 arg2 arg3 arg4   ./test.sh: line 4: : command not found [*] 4argv
- So clearly the c-shell is not able to execute the last 4 lines in the script which should be executed by csh.
However - when I add the shebang line
#!/bin/csh at the top of the script, it prints all the output correctly.
Question - Why is the csh not executing the last 4 lines correctly in first scenario and why do I explicitly have to include the shebang line?