From 4e5ab8ab046f1a7fd9f60189cace0610a08e1e8e Mon Sep 17 00:00:00 2001 From: Vidar Holen Date: Sat, 23 Jun 2018 22:53:27 -0700 Subject: [PATCH] Updated SC1001 (markdown) --- SC1001.md | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/SC1001.md b/SC1001.md index d50f7e8..fd31a56 100644 --- a/SC1001.md +++ b/SC1001.md @@ -6,11 +6,8 @@ # Want literal backslash echo Yay \o/ -# Want linefeed -greeting=Hello\nWorld - # Want other characters -carriagereturn=\r +bell=\a ``` ### Correct code: @@ -18,10 +15,7 @@ carriagereturn=\r ```sh echo 'Yay \o/' -greeting='Hello -World' - -carriagereturn=$(printf '\r') +bell="$(printf '\a')" ``` ### Rationale: @@ -30,7 +24,7 @@ You have escaped something that has no special meaning when escaped. The backsla If the backslash was supposed to be literal, single quote or escape it. -If you wanted it to expand to something, rewrite the expression. For linefeeds (`\n`), put them literally in quotes. For other characters, use POSIX `printf` or bash/ksh `$'...'`. +If you wanted it to expand to something, rewrite the expression to use `printf` (or in bash, `$'\t'`). If the sequence in question is `\n`, `\t` or `\r`, you instead get a [[SC1012]] that describes this. ### Exceptions