Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想显示我正在运行的内容,但是当命令包含空格参数时,它失败了。
#!/bin/bash go() { echo "*** $*" $* || exit 1 } go make NAME="Hi Here"
这会得到错误的行为,比如
make NAME=Hi Here
有没有更好的方法来改进 go() 函数?
将 $* 替换为 "$@":
#!/bin/bash go() { echo "*** $*" "$@" || exit 1 } go make NAME="Hi Here"