#!/bin/sh versus #!/bin/bash

Alexander Dalloz alexander.dalloz at uni-bielefeld.de
Fri Jan 9 23:31:02 UTC 2004


Am Fr, den 09.01.2004 schrieb Matthew Zimmerman um 23:57:
> I can't seem to get bash scripts to run by themselves
> if I put /bin/bash in the poundbang line of my Bash shell
> scripts . If I use /bin/sh (I run Bash interactively),
> things work normally:
> 
> ---
> matt at macko ~ $ vim test.sh
> matt at macko ~ $ chmod +x test.sh
> matt at macko ~ $ cat test.sh
> #!/bin/sh
>  
> echo Hello world
> matt at macko ~ $ ./test.sh
> Hello world
> matt at macko ~ $ . ./test.sh
> Hello world
> ---
> 
> However, if I modify the poundbang line to call /bin/bash
> instead...
> 
> ---
> matt at macko ~ $ vim test.sh
> matt at macko ~ $ chmod +x test.sh
> matt at macko ~ $ cat test.sh
> #!/bin/bash
>  
> echo Hello world
> matt at macko ~ $ ./test.sh
> ./test.sh: ./test.sh: No such file or directory

Works here without any problem.
Hint: let the shebang line be #!/bin/bash -x

> matt at macko ~ $ . ./test.sh
> Hello world
> ---
> 
> But both binaries are there:
> 
> ---
> matt at macko ~ $ ls -l /bin/{,ba}sh
> -rwxr-xr-x    1 root     root       599860 Oct 28 09:15 /bin/bash*
> lrwxrwxrwx    1 root     root            4 Dec 12 16:11 /bin/sh -> bash*
> ---
> 
> Any ideas what the heck is going on? I've noticed this on RH8
> and RH9 as well.
> 
> -- 
>       Matt

Alexander


-- 
Alexander Dalloz | Enger, Germany
PGP key valid: made 13.07.1999
PGP fingerprint: 2307 88FD 2D41 038E 7416  14CD E197 6E88 ED69 5653





More information about the fedora-list mailing list