Skip to main content
4 of 4
edited tags
Gilles 'SO- stop being evil'
  • 865.9k
  • 205
  • 1.8k
  • 2.3k

Which shell interpreter runs a script with no shebang?

Suppose the default shell for my account is zsh but I opened the terminal and fired up bash and executed a script named prac002.sh, which shell interpreter would be used to execute the script, zsh or bash? Consider the following example:

papagolf@Sierra ~/My Files/My Programs/Learning/Shell % sudo cat /etc/passwd | grep papagolf [sudo] password for papagolf: papagolf:x:1000:1001:Rex,,,:/home/papagolf:/usr/bin/zsh # papagolf's default shell is zsh papagolf@Sierra ~/My Files/My Programs/Learning/Shell % bash # I fired up bash. (See that '%' prompt in zsh changes to '$' prompt, indicating bash.) papagolf@Sierra:~/My Files/My Programs/Learning/Shell$ ./prac002.sh Enter username : Rex Rex # Which interpreter did it just use? 

**EDIT : ** Here's the content of the script

papagolf@Sierra ~/My Files/My Programs/Learning/Shell % cat ./prac002.sh read -p "Enter username : " uname echo $uname 
7_R3X
  • 1.2k
  • 2
  • 15
  • 29