[英]The fish shell and executing programs from bash through `function`
我目前正试图运行原子编辑 在bash
外壳 , 从fish
贝 。 由于ide-haskell如何处理ghc-mod
路径解析以及一些其他标准化问题,因此我在bash
运行atom
非常重要。
我是这样做的:
#~/.config/fish/config.fish
function start-atom
bash $HOME/lib/atom/bin/Atom/atom $argv
end
但是,当我尝试从fish
运行start-atom
时,我收到以下错误:
/home/athan/lib/atom/bin/Atom/atom: /home/athan/lib/atom/bin/Atom/atom: cannot execute binary file
即使我知道这个文件是正确的和可执行的。 有任何想法吗? 谢谢!
当您运行bash file_name
这意味着您尝试将file_name
作为bash脚本运行。
试试这个:
bash -c '$HOME/lib/atom/bin/Atom/atom "$@"' dummy $argv
-c
表示“使用bash运行此命令 ”而不是“使用bash运行此脚本”。
正如Charles在评论中指出的那样,我们必须进行一些调整以将参数传递给命令。 我们将它们传递给bash
,它将把它们用作提供的命令中的位置参数,因此是$@
。
应该是: bash -c '$HOME/lib/atom/bin/Atom/atom "$@"' _ $argv
下划线将成为bash的$0
演示:
$ function test_bash_args
bash -c 'printf "%s\n" "$@"' _ $argv
end
$ test_bash_args one two three
one
two
three
如果您需要该bash会话来加载您的配置,请将其设置为登录shell。
所以,底线: ~/.config/fish/functions/start-atom.fish
function start-atom
bash -l -c '$HOME/lib/atom/bin/Atom/atom "$@"' _ $argv
end
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.