Is there a difference in behaviours with respect to the flags passed to the script on the shebang line vs. using the set
builtin?
例如:
#!/bin/bash -e
# do stuff
与
#!/bin/bash
set -e
# do stuff
(The question is not specific to -e
flag but in general for any such flags).
Obviously the set [flags]
is effective only from the point it's set. But are there any other differences in functionality/behaviour?
POSIX shell中的行为也一样吗?
Some operating systems may disallow or limit the use of arguments in the shebang. No such limit would apply to a
set
command in the script itself.联机帮助页指出,“-e”具有不同的行为,这取决于是否存在POSIX模式。 除此之外,我从来没有注意到设置参数和扩展shebang之间的区别。 你为什么要问这个问题?