Improve setting temporary variable for interative use
xofyarg opened this issue · comments
What new feature should Elvish have?
In the follow use case, when running an adhoc command with a certain variable, we got a deprecation warning.
~> E:LS_COLORS= ls
Deprecation: the legacy temporary assignment syntax is deprecated; use "tmp" instead
[tty 2]:1:1-12: E:LS_COLORS= ls
The current builtin way of doing it is like below, with some extra key presses. Rely on external env
is another method.
{ tmp E:LS_COLORS = ''; ls }
It's probably more convenient, if we could improve this a little bit, e.g. wrap user input with a closure automatically.
Output of "elvish -version"
0.21.0-dev.unknown
Code of Conduct
- I agree to follow Elvish's Code of Conduct.
Why ins't the env
command (e.g., env LS_COLORS='' ls
) a reasonable solution to this problem? The cost is close to zero and adds just a couple of characters when type interactively compared to the deprecated E:LS_COLORS='' ls
syntax. If you're on Windows an Elvish env
function is reasonably straightforward to implement. Your "wrap user input with a closure automatically" comment suggests you are looking for a solution that is only applicable to interactive user input. I would argue that is an anti-pattern. That is, I think any solution to this problem should work for interactive REPL and non-interactive Elvish command blocks. Special casing interactive REPL usage seems likely to be hard to document, hard to justify, and likely to confuse users.
I will engage in the technical points later, but here are some comments as a moderator to @krader1961's comment above.
Why ins't the
env
command (e.g.,env LS_COLORS='' ls
) a reasonable solution to this problem? The cost is close to zero and adds just a couple of characters when type interactively compared to the deprecatedE:LS_COLORS='' ls
syntax. If you're on Windows an Elvishenv
function is reasonably straightforward to implement.
Please don't be dismissive of other people's preference gratuitously.
Your "wrap user input with a closure automatically" comment suggests you are looking for a solution that is only applicable to interactive user input. I would argue that is an anti-pattern. That is, I think any solution to this problem should work for interactive REPL and non-interactive Elvish command blocks. Special casing interactive REPL usage seems likely to be hard to document, hard to justify, and likely to confuse users.
Please don't use straw-man arguments.
Here is a reminder for the code of conduct for Elvish's community spaces, including the issue tracker.