Skip to content
Vidar Holen edited this page Jan 21, 2015 · 5 revisions

This expands when defined, not when used. Consider escaping.

Problematic code:

alias whereami="echo $PWD"

Correct code:

alias whereami='echo $PWD'

Rationale:

With double quotes, this particular alias will be defined as echo /home/me, so it will always print the same path. This is rarely intended.

By using single quotes or escaping any expansions, we define the alias as echo $PWD, which will be expanded when we use the alias. This is the far more common use case.

Exceptions

If you don't mind that your alias definition is expanded at define time, you can ignore this warning.

ShellCheck

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

Clone this wiki locally