From 00d92c45c8898e2ffaaa9b1ec982ada64a7d177d Mon Sep 17 00:00:00 2001 From: koalaman Date: Sat, 17 May 2014 09:26:34 -0700 Subject: [PATCH] Created SC2142 (markdown) --- SC2142.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 SC2142.md diff --git a/SC2142.md b/SC2142.md new file mode 100644 index 0000000..e1149bf --- /dev/null +++ b/SC2142.md @@ -0,0 +1,18 @@ +## Aliases can't use positional parameters. Use a function. + +### Problematic code: + + alias archive='mv "$@" /backup' + +### Correct code: + + archive() { mv "$@" /backup; } + + +### Rationale: + +Aliases just substitute the start of a command with something else. They therefore can't use positional parameters, such as `$1`. Rewrite your alias as a function. + +### Contraindications + +None. \ No newline at end of file