在 heredoc 中禁用命令替换?
Disable command substitution in heredoc?
如何在 EOF
heredoc 中禁用命令替换?
#!/bin/bash
executableFile="executableFile.sh"
firstFolder="blablabla"
cat <<EOF >$executableFile
secondFolder="blablabla2"
if [ $(cat something) == "blub" ]; then
echo $firstFolder
echo $secondFolder
fi
EOF
执行可执行文件时应请求if子句中的值
引用 'EOF'
将禁用所有特殊字符并逐字处理 heredoc。
cat <<'EOF' >$executableFile
secondFolder="blablabla2"
if [ $(cat something) == "blub" ]; then
echo $firstFolder
echo $secondFolder
fi
EOF
我也推荐double quoting all variable expansions。这并不总是必要的,但通常是必要的,这只是一个养成的好习惯。
cat <<'EOF' >"$executableFile"
secondFolder="blablabla2"
if [ "$(cat something)" == "blub" ]; then
echo "$firstFolder"
echo "$secondFolder"
fi
EOF
如何在 EOF
heredoc 中禁用命令替换?
#!/bin/bash
executableFile="executableFile.sh"
firstFolder="blablabla"
cat <<EOF >$executableFile
secondFolder="blablabla2"
if [ $(cat something) == "blub" ]; then
echo $firstFolder
echo $secondFolder
fi
EOF
执行可执行文件时应请求if子句中的值
引用 'EOF'
将禁用所有特殊字符并逐字处理 heredoc。
cat <<'EOF' >$executableFile
secondFolder="blablabla2"
if [ $(cat something) == "blub" ]; then
echo $firstFolder
echo $secondFolder
fi
EOF
我也推荐double quoting all variable expansions。这并不总是必要的,但通常是必要的,这只是一个养成的好习惯。
cat <<'EOF' >"$executableFile"
secondFolder="blablabla2"
if [ "$(cat something)" == "blub" ]; then
echo "$firstFolder"
echo "$secondFolder"
fi
EOF