Replace all "#!/bin/bash" in scripts with "#!/usr/bin/env bash" #328
KaminariOS
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
#!/bin/bash 和 #!/usr/bin/env bash 的差別
這是 絕對路徑的 shebang。
它會直接呼叫位於 /bin/bash 的 Bash。
如果你確定 Bash 永遠在這個路徑下(在大部分 Linux 上是常見的情況),就能可靠運行。
缺點:可移植性差,如果 Bash 安裝在其他位置(例如 /usr/local/bin/bash 或不在 /bin),腳本可能會失敗。
它使用 env 指令,會根據使用者的 PATH 去 搜尋 bash 並執行。
在不同系統上更具有 可移植性,因為 Bash 可能安裝在不同位置(如 /bin/bash、/usr/bin/bash、/usr/local/bin/bash)。
適合跨平臺腳本。
Beta Was this translation helpful? Give feedback.
All reactions