Shell tab in heredoc

I looked at the example of someone trying to achieve what I wanted, but it didn't work for me:-


Any suggestions about how to get a tab in a heredoc?
 
control-v tab
or
^v^i
This doesn't actually work in the instance I want to use it.

I'm intending to create a patchfile using heredoc.

The resultant patchfile is supposed to look like this:-
Code:
--- include/prereq-build.mk     2021-12-03 21:03:44.406974000 +0000
+++ include/prereq-build.mk-FreeBSD-getopt      2021-12-03 21:56:19.603555000 +0000
@@ -130,6 +130,7 @@
        Please install an extended getopt version that supports --long, \
        gnugetopt -o t --long test -- --test | grep '^ *--test *--', \
        getopt -o t --long test -- --test | grep '^ *--test *--', \
+       /usr/local/bin/getopt -o t --long test -- --test | grep '^ *--test *--', \
        /usr/local/opt/gnu-getopt/bin/getopt -o t --long test -- --test | grep '^ *--test *--'))

 $(eval $(call SetupHostCommand,stat,Cannot find a file stat utility, \

My actual code consists of:-
Code:
cat <<EOF >patchfile
--- include/prereq-build.mk<--->2021-12-03 21:03:44.406974000 +0000
+++ include/prereq-build.mk-FreeBSD-getopt<---->2021-12-03 21:56:19.603555000 +0000
@@ -130,6 +130,7 @@
    Please install an extended getopt version that supports --long, \\
    gnugetopt -o t --long test -- --test | grep '^ *--test *--', \\
    getopt -o t --long test -- --test | grep '^ *--test *--', \\
\+<---->/usr/local/bin/getopt -o t --long test -- --test | grep '^ *--test *--', \\
    /usr/local/opt/gnu-getopt/bin/getopt -o t --long test -- --test | grep '^ *--test *--'))
 
 \$(eval \$(call SetupHostCommand,stat,Cannot find a file stat utility, \\
EOF

The problem occurs when I insert a TAB using '^v^i' on a line which starts with a '+'.

The patch gets rejected:-

Hmm... Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|--- include/prereq-build.mk 2021-12-03 21:03:44.406974000 +0000
|+++ include/prereq-build.mk-FreeBSD-getopt 2021-12-03 21:56:19.603555000 +0000
--------------------------
Patching file include/prereq-build.mk using Plan A...
Hunk #1 failed at 130.
1 out of 1 hunks failed--saving rejects to include/prereq-build.mk.rej
done

The reject looks like:-

@@ -130,6 +130,7 @@
Please install an extended getopt version that supports --long, \
gnugetopt -o t --long test -- --test | grep '^ *--test *--', \
getopt -o t --long test -- --test | grep '^ *--test *--', \
+<----->/usr/local/bin/getopt -o t --long test -- --test | grep '^ *--test *--', \
/usr/local/opt/gnu-getopt/bin/getopt -o t --long test -- --test | grep '^ *--test *--'))
.
$(eval $(call SetupHostCommand,stat,Cannot find a file stat utility, \


Looks like patch does not like this TAB character after a '+'.
 
Back
Top