【发布时间】:2013-11-01 13:13:40
【问题描述】:
我有 bash 脚本,它需要 bash。
另一个人尝试用
运行它sh script_name.sh
它失败了,因为 sh 在他的发行版中是 dash 的符号链接。
$ ls -la /bin/sh
lrwxrwxrwx 1 root root 4 Aug 25 16:06 /bin/sh -> dash
我有一个使用包装脚本的想法:
#!/bin/sh
bash script_name.sh
目标是通过 sh 和 bash 在系统中运行 .sh 脚本,该系统具有指向破折号的符号链接。
【问题讨论】:
-
如果你只做
./script_name.sh呢? -
或者让其他用户使用
bash script_name.sh运行? - 包装器也可以。你有什么问题? -
你应该展示你的脚本。您想要的是更改您的脚本,使其严格符合 Posix
sh标准。 -
奇怪,如果
/bin/sh指向破折号,那么这个系统上可能没有真正的/bin/sh -
那么你应该声明
bash是明确需要的,脚本应该以/bin/bash script_name.sh运行,并以#!/bin/bash启动该脚本......
标签: linux bash shell sh dash-shell