Easier string interpolation of env variables #12750
Labels
enhancement
New feature or request
quoting/expansion
Issues related to string quoting and expansion of variable or glob patterns
syntax
Changes to the grammar or syntax beyond parser bugfixes
Related problem
I am loving nushell. I think what would make it even better would be to make env variable interpolation into strings easier.
In bash, I can use string interpolation of env variables as follows
In nushell, this would become the more verbose
This is 15 more key strokes for the same command. Obviously it is safer and more readable, but it is also many more key strokes for a simple interpolation that I am using out of convenience.
Describe the solution you'd like
I would like to propose an "env string" macro syntax which automatically put the env variables into context before interpolating, so that I don't need to write out so many characters each time.
For example, the above command would become
This is an 8-keystroke reduction for the same command, at no loss to safety or readability.
The
e"..."
would be a macro that automatically loads all env variables into context before interpolating as an$"..."
. Other variables would not be passed through. So for example, if you hadthis would fail to interpolate
x
unless you had defined$env.x
. I believe this is the safer option in case you accidentally refer to a variable not in the env.Describe alternatives you've considered
(Not applicable)
Additional context and details
Semi-related issue here: #2317.
str expand
is suggested for brace expansion. However, this does not work for interpolating env variables.Happy to discuss other ideas here as well. Really anything that reduces the key strokes in string interpolation for env variables would be fantastic!
The text was updated successfully, but these errors were encountered: