Which characters are allowed in a bash alias

前端 未结 4 1721
北恋
北恋 2021-02-14 00:05

I recently added

alias ..=\'cd ..\'
alias ...=\'cd ../..\'
alias ....=\'cd ../../..\'

to my bash_aliases file. Playing around with this, I not

4条回答
  •  失恋的感觉
    2021-02-14 00:40

    According to the following environment variables names can only contain

    uppercase letters, digits, and the '_' (underscore) from the characters defined in Portable Character Set and do not begin with a digit. Other characters may be permitted by an implementation; applications shall tolerate the presence of such names.

    But variables are not really the same the same of alias names.

    In practice a -(dash) should be added to the list because it is a defacto standard in debian(apt-get). In addition _~@#%^., all work and ><'"|=()backtick/?[]+!. don't. In addition you have to worry about $PATH and characters like :. It appears space and linebreaks could work if they are properly escaped or quoted like so "a b".

提交回复
热议问题