It isn't clear exactly what more needs to be escaped in the following macro to allow it to be used with awk or sed on FreeBSD.
define(`RELAY_MAILER_ARGS', `TCP $h 2525')dnl
Here is an awk command that attempts to insert the above line at line 90 below the SMART_HOST
configuration.
awk 'NR==90 { print "define(\`RELAY_MAILER_ARGS\', \`TCP $h 2525\')dnl"}1' example.com.mc
The command results in the following error:
Unmatched '"'.
Note to future editors: the backtick/single quote is not a typo. This is an ancient quirk of the m4 language that is used to write the macros for Sendmail configuration: "m4 uses single quotes (opening "`" and closing "'") to quote arguments"
Additional Note: Octal escapes don't seem to work when using sed
on FreeBSD. In that situation, use the xNN
escaped hexadecimal characters in that situation.
You cannot escape single quotes as the command itself is surrounded by single quotes, but you could use an octal escape code
\047
to represent'
in POSIX awk. Additionally, you could use a hexadecimal escape code\x27
in GNU awk (gawk
).From The GNU Awk User’s Guide, 3.2 Escape Sequences:
If you would like to also use
\140
(or\x60
) to represent the backtick: