Skip to content
koalaman edited this page May 17, 2014 · 6 revisions

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.

ShellCheck

Each individual ShellCheck warning has its own wiki page like S001. Use GitHub "Pages" feature above to find a specific one, or see Checks.

Clone this wiki locally