我已将mill
fish作为默认shell安装在arch linux上。由于文件/usr/bin/mill
不是以shebang开头的,因此fish不会执行该文件。相反,它以
$ mill
Failed to execute process '/usr/bin/mill'. Reason:
exec: Exec format error
The file '/usr/bin/mill' is marked as an executable but could not be run by the operating system.
我可以执行mill,bash -c 'mill'
但是我不想一直这样做。我也不想仅将其添加为米尔的别名。当脚本中没有shebang而不失败时,是否可以将fish配置为始终使用sh或bash?还是可能存在操作系统级别的问题?
编辑:米尔只是一个例子。我用不应该编辑的不同脚本无数次遇到了fish的此功能。这就是为什么我正在寻找一种永远避免该功能的方法,而不是仅仅针对磨机的一次性解决方案。
你不能那样做。
您可以检查其源代码:
execve(actual_cmd, argv, envv);
err = errno;
// Something went wrong with execve, check for a ":", and run /bin/sh if encountered. This is a
// weird predecessor to the shebang that is still sometimes used since it is supported on
// Windows. OK to not use CLO_EXEC here because this is called after fork and the file is
// immediately closed.
注意如何使用它的execve
(不是execvp
或execlp
,其中有一个跌落回/bin/sh path
的情况下ENOEXEC
),并用它只会运行脚本/bin/sh
,如果它开始:
(这本身就是一个可疑的特征,尤其是fish
还将利用它在其他错误的情况下,比ENOEXEC
)。
但是,如果您可以编辑脚本以:
在开头添加一个,则也可以对其进行编辑以添加适当的she-bang。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句