Single or Double quotes when defining an alias?

This is an answer to the question posed by the title (which brought me here), rather than to the OP's particular question.

Single quotes are evaluated dynamically:

alias QS='echo $PWD'

Double quotes are evaluated at time of creation and, thereafter, never changes:

alias QD="echo $PWD"

The same behaviour is found in bash, zsh and, I guess, other shells.


In the example you mention, where the expansion for the alias is a single word containing no character that is subject to expansion, it makes no difference how you quote the name _cutf:

$ alias cutf="_cutf"
$ alias cutf
alias cutf='_cutf'

$ unalias cutf
$ alias cutf='_cutf'
$ alias cutf
alias cutf='_cutf'

$ unalias cutf
$ alias cutf=_cutf
$ alias cutf
alias cutf='_cutf'

As you can see in that interaction, recalling the value of the alias cutf gave the same result each time. So, yes, the quoting styles are interchangeable here.

It is not relevant that the expansion is to a function name: at least with bash, aliases perform a simple textual substitution (it is not obvious to me in what way defining an alias is useful; directly calling the underlying function seems just as easy).


It's just that simple - if there's no variable, the brackets are interchangeable. Shell script, while very useful, is also a very simple language. I (and some others I know) tend to use double quotes by default, just from force of habit - and I have never run into issues.