在鱼的同一行使用eval和background一个进程

问题描述 投票:0回答:1

如何使用eval在变量中执行命令并将其置于同一行中?我正在尝试以下但它不起作用。例如s xeyes我希望shell返回。

function s --description "Start a command in the background and remove from jobs list"
    echo (count $argv)
    if test (count $argv) -ne 1 
        echo "illegal number of parameters"
        return 1
    end
    eval $argv[1] 2>&1 > /dev/null &
    disown
end
fish
1个回答
0
投票

Fish不支持背景功能。 eval是一个函数,因此不支持后台。

你需要将&放入eval'd代码,所以

    eval $argv[1] 2>&1 > /dev/null &

可能有用。

或者,因为这里不再需要鱼3.0 eval,所以你可以这样做

 $argv[1] 2>&1 >/dev/null &
© www.soinside.com 2019 - 2024. All rights reserved.