【发布时间】:2013-08-08 20:38:28
【问题描述】:
我在其中一台 linux 主机(bash 版本 3.2.25(1))上运行 bash 脚本很好,因为我已将脚本移动到另一台主机(bash 版本 4.2.25(1))它正在抛出警告
line 36: warning: here-document at line 30 delimited by end-of-file (wanted `EOM') (wanted `EOM')
有问题的代码是:-(不确定 EOM 是如何工作的)
USAGE=$(cat <<EOM
Usage:${BASENAME} [-h] [-n] [-q]
-h, --help This usage message
-n, --dry-run
-q, --quiet
-d, --Destination
EOM)
}
我已确保在 EOM 前后没有空格、制表符或任何特殊符号,因为这是在 google 研究期间发现错误的原因。
bash (bash -x) 调试后的输出如下:-
+ source /test/test1/script.sh
./test.sh: line 36: warning: here-document at line 30 delimited by end-of-file
(wanted `EOM')
++ cat
+ USAGE='Usage:test [-h] [-n] [-q]
-h, --help This usage message
-n, --dry-run
-q, --quiet
-d, --Destination
这是采购一个 script.sh ,其中使用在以下函数之一中: (但我猜这不是错误的原因,但可能是我错了)-
show_usage()
{
declare -i rc=0
show_error "${@}"
rc=${?}
echo "${USAGE}"
exit ${rc}
}
请帮助并摆脱这个警告以及这个 EOM 是如何在这里工作的?
【问题讨论】:
-
@tripleee 欺骗目标不是很好,因为它在问题中包含看似正确的代码,所有答案都只是猜测原因可能是什么,而在这个问题中,这里的原因-doc 失败是显而易见的。在寻找 stackoverflow.com/questions/44030479/… 的骗子时遇到了它;这个问题在这里似乎比它的欺骗目标要好得多。
标签: bash