From: Zbigniew Jędrzejewski-Szmek Date: Sun, 11 Jun 2017 19:24:07 +0000 (-0400) Subject: Use "dollar-single-quotes" to escape shell-sensitive strings X-Git-Tag: chiark/234.4-1+devuan1.1+iwj1~109 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=commitdiff_plain;h=94678e2009c5eb2fa259d4f74f7b055ddda38d9e;hp=94678e2009c5eb2fa259d4f74f7b055ddda38d9e Use "dollar-single-quotes" to escape shell-sensitive strings Also called "ANSI-C Quoting" in info:(bash) ANSI-C Quoting. The escaping rules are a POSIX proposal, and are described in http://austingroupbugs.net/view.php?id=249. There's a lot of back-and-forth on the details of escaping of control characters, but we'll be only using a small subset of the syntax that is common to all proposals and is widely supported. Unfortunately dash and fish and maybe some other shells do not support it (see the man page patch for a list). This allows environment variables to be safely exported using show-environment and imported into the shell. Shells which do not support this syntax will have to do something like export $(systemctl show-environment|grep -v '=\$') or whatever is appropriate in their case. I think csh and fish do not support the A=B syntax anyway, so the change is moot for them. Fixes #5536. v2: - also escape newlines (which currently disallowed in shell values, so this doesn't really matter), and tabs (as $'\t'), and ! (as $'!'). This way quoted output can be included directly in both interactive and noninteractive bash. ---