【发布时间】:2017-12-20 16:02:50
【问题描述】:
我正在编写一个涉及使用< <() 进行进程替换的 Korn shell 脚本,如下所示:
array=()
while IFS= read -r -d '' x;do
array+=( "$x" )
done < <(some command)
这是试图将some command 返回的所有字符串插入array。奇怪的是,当我的 shebang 看起来像这样时,这会起作用:
# !/usr/bin/ksh
这当然是不寻常的(注意# 和! 之间的空格)。另一方面,当我的 shebang 看起来像 #!/usr/bin/ksh(显然是正确的方式)时,此脚本将失败并出现错误 syntax error: '< ' unexpected。为什么是这样?在 shebang 中有一个空间意味着什么?谷歌给了我几个答案,说!# 和!/usr... 之间的空格是可以的,但没有关于! 和# 之间的空格。
【问题讨论】: