Hi,
I have a question about code formatting in eg. dietpi-config files. Is there a reason for not escaping spaces in here docs with configuration and moving those blocks inline with line above?
I mean:
# some previous code
cat <<-EOF > /dev/null
[magical config option]
something magical
EOF
instead of current:
# some previous code
cat <<EOF > /dev/null
[magical config option]
something magical
EOF
This brakes code folding in ide’s - could this be refactored?
better to ask such questions directly on GitHub as this will reach our developer @MichaIng way faster as via our forum.
I saw this syntax just recently. Does it support as well:
cat << -'EOF' > file
some lines
EOF
to assure everything is taken literally, including $
etc? And does it remove really all leading spaces or just those until the cat
command? Because often we want leading spaces in the resulting file.
One reason why I did not further consider/think about it is that with the indentation one cannot copy&paste here document content from code to console text editors anymore. It happens quite often that I am manually creating a file created via here document in one of our scripts for testing reasons. And it would be horrible if I needed to remove all the indentation manually for every line, so assure it is identical (even if whichever reads the file supports leading spaces).
But I agree that here documents currently break consistent indentation and do not look nice in code. Probably there is a feature/plugin for notepad++ and other editors to select and copy here documents a way that those leading spaces are not selected/copied.