Created SC2142 (markdown)

koalaman
2014-05-17 09:26:34 -07:00
parent 030e1e47f0
commit 00d92c45c8

18
SC2142.md Normal file

@@ -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.