This is deceivingly complicated. I need a regular expression to highlight comments from Bash shell scripts.
Keep in mind that $# , ${#foo} , string="this # string" , string='that # string' , ${foo#bar} , ${foo##baar} and
string="really complex args=$# ${applejack##"jack"} $(echo "$#, again")"; `echo this is a ${#nasty[*]} example`
- All valid shell expressions that should not be removed.
Edit: Note:
# This is a comment in bash
Edit: Please note that lines that may be misinterpreted as comments may be refilled inside the HEREDOC, but since this is a multi-line line, I can live without processing / accounting:
cat<<EOF>>out.txt This is just a heredoc
Jeffg source share