I want to display what I'm running, but when the commands contain space parameter, it failed.
#!/bin/bash
go() {
echo "*** $*"
$* || exit 1
}
go make NAME="Hi Here"
That will get wrong behavior like
make NAME=Hi Here
Is there any better method to improve the go() function?
Replace $* with "$@":
#!/bin/bash
go() {
echo "*** $*"
"$@" || exit 1
}
go make NAME="Hi Here"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.