标题: set -- 的用法 [打印本页] 作者: zhuyubei 时间: 2011-05-22 21:24 标题: set -- 的用法 我最近看到这样的代码
假设
echo $line 的结果是
sadasd:ddddd
OLD_IFS="$IFS"; IFS=: ; set -- $line; IFS="$OLD_IFS"
a=$1
b=$2
echo "[$a and $b]" 的结果就是: [sadasd and ddddd]
也就是说$line被以:为分割符分割开了,分后的字段分别保存在$1和$2这2个参数里。
我看了set --的用法,好像是说:
If no arguments follow this option, then the positional parameters are unset. Otherwise, the positional parameters are set to the args, even if some of them begin with a -
但是我对其用意还不是很明白。有高手能解释下set --的背后原理吗?作者: xiaopan3322 时间: 2011-05-22 21:42
set --