>> In my Bash scripts, I indent using spaces instead of tabs but I'd still like 
>> to get this behavior. Why not strip leading whitespace?

>...
>To get the equivalent of your proposed change without modifying the
>shell in a way that would violate the definitions, you could replace
>cat with sed:

>        sed 's/^[[:space:]]*//' <<-'EOF'
>        These lines
>        are indented
>        with spaces
>EOF

>The only eyesore would be the delimiter word, which can't be indented
>with spaces.

There are always workarounds...

The above "sed" solution doesn't really scale if your actual command
is anything other than "cat" (Yes, I know there will be objections to
this statement, but it is true nonetheless)

The real point is that OP is not the first person in the world to have
noticed this glitch in the definition of here documents.  It is kind
of like Makefile, where the same anomaly attaches -> tab(s) and nothing
else.  Like the weather, everybody complains, nobody does anything
about it.

It would probably be possible to add a new operator (e.g., <<--) to
mean strip all leading whitespace, but I doubt it will ever be high
enough on anyone's TODO list to get done.

=================================================================================
Please do not send me replies to my posts on the list.
I always read the replies via the web archive, so CC'ing to me is unnecessary.

When responding to my posts, please try to refrain from giving bureaucratic 
answers.
If you have nothing useful to say, then just click Next and go on.

Reply via email to