Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Acessing variables as $varname #139

Open
dundalek opened this issue Apr 27, 2019 · 0 comments
Open

Acessing variables as $varname #139

dundalek opened this issue Apr 27, 2019 · 0 comments

Comments

@dundalek
Copy link
Owner

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}").

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant