[英]How to set argments after heredoc in Bash
I'd like to modify the following script to 我想将以下脚本修改为
tmp=$(cat <<'EOT'
ssh user@sv7247.xserver.jp
EOT
)
expecto "${tmp}" "${PASSWORD}"
like following script because just I want to make short the script. 之所以喜欢下面的脚本,是因为我想简化该脚本。
expecto "$(cat <<'EOT' "${PASSWORD}"
ssh user@sv7247.xserver.jp
EOT
)"
However the shorted script not work. 但是,短脚本无法正常工作。 It is seems to caused by the second argment "${PASSWORD}"
is not recognized. 似乎是由于第二个参数"${PASSWORD}"
未被识别引起的。
How is the corrent way to do that thing? 如何做这件事的正确方式?
You would write: 你会这样写:
expecto "$(cat <<'EOT'
ssh user@sv7247.xserver.jp
EOT
)" "${PASSWORD}"
Your readability is really suffering there. 您的可读性确实在那儿受苦。 I would think twice about cramming that all together. 我会三思而后行地挤在一起。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.