Acessing variables as $varname
dundalek opened this issue · comments
In bash a variable valuable can be accessed with the dollar sign $varname
. That gets value of a local variable and fall backs to environment variable.
In closh it is currently done with (str varname)
and (getenv "varname")
which can become quite chatty. I am considering whether we should expand variable value with dollar sign too. Should we also fall back to environment variable?
With the fall back $varname
could become something like:
(if-let [resolved (resolve 'varname)] (deref resolved) (getenv "varname"))
Another thing is expansion in strings: "$a/${b}"
. Here are am leaning against it since it gets complicated with escaping rules.
Workaround can be to used some string interpolation library like strint/<< or cuerdas istr: (istr "~{a}/~{b}")
. But maybe we could try to create a library to implement this in a bash compatible way like ($ "$a/${b}")
.