Variable expansion syntax proposition
Created by: nounoursheureux
While the current syntax $var
is great thanks to its simplicity, I think it can be inconvenient. Here is an example in the form of an imaginary PROMPT variable:
let PROMPT = "$USERNAME@$CWD:$SUFFIX"
The problem here in my opinion is that is can be unclear when a variable's name ends. In this particular case it is easy because I used special characters, but if I wanted to use a
instead of @
it wouldn't work (the parser would use $USERNAMEa
as the variable name). So i suggest that we use the following syntax instead: ${var}
. In my opinion it is as readable as $var
while avoiding ambiguity. And so our PROMPT variable would be:
let PROMPT = "${USERNAME}@${CWD}:${SUFFIX}"
What do you think ?