[英]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.