From 9b3e0d6e1ebeb8bd60d0adda4f32f487eacb6982 Mon Sep 17 00:00:00 2001 From: "David A. Wheeler" Date: Sun, 1 Dec 2013 08:06:49 -0800 Subject: [PATCH] Created SC2039 (markdown) --- SC2039.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 SC2039.md diff --git a/SC2039.md b/SC2039.md new file mode 100644 index 0000000..2e3bac0 --- /dev/null +++ b/SC2039.md @@ -0,0 +1,6 @@ +The $'...' construct is widely supported and in the process of being standardized, but it is not yet standard. Many shells do support it, including bash, ksh, zsh, and the busybox "sh" command. Since it is useful, POSIX has recently accepted $'...' (see http://austingroupbugs.net/view.php?id=249 ). However, POSIX-2013 does not include $'...', so a few shells do not yet support it. For now, be more specific about the shell, or use another construct (printf can often do the job). + +The $(...) construct strips trailing newlines. You can retain trailing newlines using this trick: + + newline="$(printf '\nX')" + newline="${newline%X}