i think the real error was that you started the echo with a double quote and ended with a single quote. had you properly wrapped it with single quotes it would have worked. even if you had escaped the double quote, there still would have been an error because you'd have a multi-line string with no ending " (the 2nd double quote was properly escaped so that would not have terminated your string)
Also, you didn't escape your slashes.
Either it should have looked like this:
echo '# FYI quotes(") must be escaped with \ like \"'
or this:
echo "# FYI quotes(\") must be escaped with \\ like \\\""
No, because neither of those are the inputs. The input was the systemd file in the image. The whole command was not printed in the error, only surrounding context. The single-quote was indicating the ending of that context(because it was the end of the line) printed by the error.
The same thing was done with `)' on the first line of error
I'm reading this and interpreting that line 27 of that script is
sudo echo "# FYI quotes(") must be escaped with \ like \"
I am confused why there is no trailing double quote, the last 3 chars should be \"" so perhaps this is a bad assumption but the best I can do with the available information.
So the fix here is to change startup-script line 27 so that you're not echoing things that might contain characters that might be interpreted by echo or your shell.
Now if startup-script is provided by your distro, there may be a reason that it's using echo, but I will tell you now whatever dipshit reason they provide they're fucking wrong because EXHIBIT A:
# " fucks the script and rule 0 of linux is "don't break userspace".
Everything else allows any printable char after the # in a comment, that script is not special, comments are not to be interpreted by the program. That is a show-stopping bug in startup-script and must be fixed.
sudo echo "# FYI quotes(") must be escaped with \ like \"
👆 that is not a comment. That is a command that says to echo the text "# FYI quotes(" and then to do ) must be escaped like \ \" which is invalid syntax.
I assume that startup script is reading the contents of the file and trying to echo them into another file? i.e., using the original file as a template, but is not escaping the input, hence the error — which you’re lucky that’s the problem you’re encountering and not something actually destructive like sudo echo "# foo" && rm -rf /*.
It’s all good. If you’re using bash and readline to read the file, you can use sudo echo ${INPUT@Q} (assuming your variable is named $INPUT) to have bash escape things like the quotes and other characters that could get you into trouble.
I don't know the system in question, but it's definitely a bad design when comments need to be written with care. Either you set this up in a really wonky way, or the system you're using did and it should be fixed ASAP.
What code is in charge of injecting things into a shell script?
I've gone back and forth between a common bashrc file in my Dropbox folder that is symlinked to ~/.bashrc on my devices, and one that is imported from a regular bashrc instead, and recently it ended up in a state where it accidentally tried to do both, resulting in an endless loop. I discovered this on my Pop!_OS PC, which reacted to this situation by crashing on login lol. What??