Skip to content
Joachim Ansorg edited this page Nov 12, 2021 · 7 revisions

Tilde does not expand in quotes. Use $HOME.

Problematic code:

rm "~/Desktop/$filename"

Correct code:

rm "$HOME/Desktop/$filename"

Rationale:

Tilde does not expand to the user's home directory when it's single or double quoted. Use double quotes and $HOME instead.

Alternatively, the ~/ can be left unquoted, as in rm ~/"Desktop/$filename".

Exceptions

If you don't want the tilde to be expanded, you can ignore this message.

Related resources:

ShellCheck

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

Clone this wiki locally