
On 25/09/2020 15.38, Heinrich Schuchardt wrote:
On 25.09.20 15:09, Wolfgang Denk wrote:
Dear Heinrich Schuchardt,
In message 4b00225d-d960-4a14-9aec-110ddddf7f30@gmx.de you wrote:
Further we cannot first introduce a command call and then eliminate it due to backward compatibility. We should decide on the final version beforehand.
Full agreement. we need a concept of what is needed / wanted first. And then we should look how current vrsions of hush fit into this.
In the Linux world you can override a command using an alias. So I am not sure if a built in command should take precedence over a variable of the same name or the other way round.
This is simple. The PoLA (Principle of Least Astonishment) applies here. Behaviour must be the same as in other (to some extent POSIX compatible) shells. A shell should parse it's input, not adhoculate it.
For me this could be realized by enhancing the run command to allow:
run varname1 varname2 ... varnameN --args argv1 argv2 argv3
Arguments argv1, argv2, ... are passed to the script identified by the last variable (varnameN).
No new command to learn. Just a new option.
Yes, this is really more to be thought of as a "run_with_args" command than an extension of hush (though the $1 treatment does need to hook into the hush code, which is both why I made it dependent on HUSH_PARSER and made it live in cli_hush.c). I'm certainly open to extending the existing run command instead of creating a new "toplevel" command. Though I'd probably make it
run varname -- arg1 arg2 arg3
instead: Just use -- as a separator [that has precedent as "stop doing X, use the rest as argv", though X is normally "interpret options" and now it would be "read function names to run"], and only allow a single "function" to be called. Otherwise, I don't there's any natural answer to whether all the varnameX or only the last should be called with the positional arguments. It's pretty simple to do "for x in v1 v2 v3; do run $x -- arg1 arg2 arg3 ; done if one has a bunch of functions that should be called in turn, and it's even more simple to do
run varname1 varname2 varname{N-1} run varnameN -- arg1 arg2 arg3
if one has a bunch of parameter-less functions to call before varnameN.
Rasmus
Rasmus