0

I' trying to add this command to a docker-compose file to modify sendmail config at startup:

bash -c 'sed -i.backup -e "/FEATURE(\`no_default_msa\')dnl/a  define(\`SMART_HOST\', \`smtp.acme.priv\')dnl" /etc/mail/sendmail.mc'

It's just a regular sed, except sendmail config contains tons of single quotes and back quotes, so it returns this:

-su: syntax error near unexpected token `)'

I know it comes from quotes inside quotes. I tried to arrange it following some over thread, but it's a terrible mess.

Any bash guru specialized in escape characters here to help me?

Thanks!

Bibelo
  • 221
  • 2
  • 8
  • Does this answer your question? [How can I escape a double quote inside double quotes?](https://stackoverflow.com/questions/3834839/how-can-i-escape-a-double-quote-inside-double-quotes) – jeremysprofile Nov 03 '20 at 16:21
  • You will find it slightly easier if you elect to use double quotes as the first, top-level set, inside of which you can escape instances of double quotes and have one fewer layers of escaping to be done on single quotes. My preferred way to do these things, however, is to use a heredoc: `bash <<-'EOF'`. This negates the need to do any additional escaping at all. – CJK Nov 04 '20 at 08:36
  • I used a workaround. Thank you for your answers though – Bibelo Nov 12 '20 at 10:30

0 Answers0