执行上一条命令的结果

时间:2019-10-25 12:01:35

标签: bash shell

我想脚本将我的remote.origin.url从https更新为git

我想到了

IN=$(git config --get remote.origin.url)
arrIN=(${IN//@/ })
echo "git@"${arrIN[1]} | bash -s git remote set-url origin 

我的回声线似乎显示正确

git@bitbucket.org:bh/app.git

我做错了什么?

1 个答案:

答案 0 :(得分:1)

-s告诉bash从stdin读取命令。不是完整的命令,不是您在命令行上给出的命令的参数。它会忽略命令行上的任何命令。

$ echo 'echo test command' | bash -s 'echo this command is ignored'
test command

您不需要bash -s。您可以将所需的字符串附加到git remote set-url命令中。

git remote set-url origin git@"${arrIN[1]}"