遍历空字符串

loop through empty string

最近发现一段代码让我很困惑:

typeset _Var=''

for _Var
do
   ... a command
done

谁能解释一下循环遍历空值列表的工作原理?

非常感谢 post。

结构

for var
do
    echo something
done

没有 in 关键字将默认为位置参数列表,例如 </code>、<code>

因此您的脚本将为每个单独的循环体执行一次 命令行参数。

上面调用的代码片段 ksh testscript a b c 将输出:

something
something
something