3

I would like to declare an alias (in my .bash_profile) that will use the content (value) of a variable when the alias is used, not when it is defined. E.g.,

alias goSomeWhere="cd $BASE/somewhere"

$BASE is not set when the alias is defined, only when is it used. But, because $BASE is evaluated when the alias is defined (at login time), the goSomeWhere alias is interpreted as cd /somewhere.

How can I delay the evaluation of the variable until the alias is executed?

4

Replace both " by ' or prefix $ with a \.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.