From 894edc2ee5f828fde93e31ce52273950f3a3cdeb Mon Sep 17 00:00:00 2001 From: Vidar Holen Date: Sat, 23 Jun 2018 16:38:37 -0700 Subject: [PATCH] Updated SC2142 (markdown) --- SC2142.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/SC2142.md b/SC2142.md index 9d9e802..e1304c0 100644 --- a/SC2142.md +++ b/SC2142.md @@ -21,6 +21,9 @@ Aliases just substitute the start of a command with something else. They therefo If your alias ends up quoting the value, e.g. `alias cut_first="awk '{print \$1}'"`, you can technically [[ignore]] this error. However, you should consider turning this alias into a more readable function instead: `cut_first() { awk '{print $1}' "$@"; }` +You can also [[ignore]] this warning if you intentionally referenced the positional parameters of its relevant context, knowing that it won't refer to the parameters of the alias itself. For example, `alias whatisthis='echo "This is $0 -$-" #'` will show the shell name with flags, i.e. `This is dash -smi` or `This is bash -himBs`, and is correct usage because it does not intend for `$0` to reflect anything related to the `whatisthis` alias or its invocation. + + ### Related resources: * [BashFaq: How can I make an alias that takes an argument?](https://mywiki.wooledge.org/BashFAQ/080)