Shell ${ABI} in heredoc

The quotes that you put around the end-of-file tag apply to the whole heredoc. So assuming you want the have $PATH literally in the output:
Code:
[f12.185] $ cat - <<'EOF'
> $PATH
> EOF
$PATH
 
For completeness, backslash quoting also prevents parameter expansion:
Code:
[ritz.263] $ cat - <<EOF
> \$PATH
> EOF
$PATH
 
The quotes that you put around the end-of-file tag apply to the whole heredoc. So assuming you want the have $PATH literally in the output:
Code:
[f12.185] $ cat - <<'EOF'
> $PATH
> EOF
$PATH
I hadn't heard about using quotes before but that managed to get me sorted.

The problem was that I had a heredoc within a heredoc and the ${ABI} was inside the other one but I did manage to find a solution combining both methods you mentioned using the following code:-
Bash:
# pkg stuff


#
#  /etc/pkg/FreeBSD.conf
#

cat <<EOF >/mnt/install/etc/rc.d/firstboot
sed -n 6,7p /etc/pkg/FreeBSD.conf | sed 's/^# *//' | sh
EOF
chmod a+x /mnt/install/etc/rc.d/firstboot
touch /mnt/install/firstboot

cat <<'EOF' >>/mnt/install/etc/rc.d/firstboot
cat <<EOF2 >/usr/local/etc/pkg/repos/local-repo.conf
local-repo: {
    url: "file:///mnt/pkg-repo/\${ABI}/quarterly",
    signature_type: "none",
    enabled: yes
}
EOF2
EOF
 
The quotes that you put around the end-of-file tag apply to the whole heredoc. So assuming you want the have $PATH literally in the output:
Code:
[f12.185] $ cat - <<'EOF'
> $PATH
> EOF
$PATH

Ah, I could have used that an hour ago. Glad it was right here today because I came looking for just this exact answer. Thanks.
 
Back
Top