2015年12月1日 星期二

BASH: invoked by sh enter POSIX mode

Bash Reference Manual: Bash POSIX Mode
http://www.gnu.org/software/bash/manual/html_node/Bash-POSIX-Mode.html

 invoked as sh, Bash enters POSIX mode after reading the startup files.

Execute the following script with bash and sh, which also links to sh, get the different result:
~$ cat a
#!/bin/bash
echo a

~$ cat test
#!/bin/bash
source a
echo b

~$ ls /bin/sh -alh
lrwxrwxrwx 1 root root 4 12月  1 16:30 /bin/sh -> bash

~$ bash test
a
b

~$ ./test
a
b

~$ sh test
test: line 2: source: a: file not found




沒有留言: