Remove trailing newline from esyscmd in m4

devnull's example is good but, M4 has a builtin tr as well. Here's what I'm doing:

define(CMD_OUTPUT, esyscmd(`sass --style=compressed foo.sass'))
define(NL,`
')
translit(CMD_OUTPUT, NL)

Someone a little better with M4 could tighten that into a single macro.


*nix systems have tr by default. Make use of that:

define(MY_HOSTNAME, esyscmd(sh -c "hostname | tr -d '\n'"))

and you'd get rid of the trailing newline!

Tags:

Shell

Bash

M4