- 论坛徽章:
- 7
|
${1+"$@"} 和 "$@"有何区别?
这有一段老外的帖子
- > egrep: #!/bin/sh
- > exec grep -E ${1+"$@"}
- >
- > The parameter is just an improved replacement of the traditional $*, this is OK.
- > (BTW: I don't understand why simple "$@" is not enough.)
- Some shells expand "$@" like "" (a single empty argument) when there
- are no arguments. ${1+"$@"} correctly expands to no arguments on
- those shells.
- However, it breaks on zsh, which is used as /bin/sh on Mac OS X,
- unless you first do:
- case "$ZSH_VERSION" in ?*) alias -g '${1+"$@"}'='"$@"';; esac
复制代码 |
|