Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: why is eval needed?



On 2022-11-20 00:55, Stephane Chazelas wrote:


It's the caller's role to pass tree, -L and 1 as separate

arguments.
Yeah I get it.  The first time I 'got it' was when discussing 'aptitude' and the various quotings needed.  Again one is creating an invisible level of organization imposed on a string of characters.  Where it got confusing was when zsh imposed it's own ideas of grouping, making '-L 2' into a single entity.  Dunno if it's really a thing to be desired but naively one might like some way of assembling a command string as if it was at CLI, that is *just* a string of characters -- which is how I was looking at it.
tree parses its options. It looks like it does not use the
standard getopt() API or the GNU getopt_long() API for that:

$ nm -D =tree | grep -i getopt
$ ltrace -e '*opt*@*' tree > /dev/null
+++ exited (status 0) +++
What are you doing there?  I have no 'nm' command here.  No such command in Debian repository.

So it must be doing it by hand.
Yeah, so much in the GNU/Linux world is ad hoc.  Everybody did their own thing.  No rules.
In any case zsh (or perl) has no saying on how tree may parse
its options. You have to invoke it the way its meant to be
invoked and in the case of tree, the option arguments must be
passed as separate arguments.
Sure.  The main thing is to just understand that.  Not too difficult when you do, something might need splitting or joining but it won't take long to figure out.  But why does calling 'eval' fix it?  It seems as if eval 'flattens' everything -- one is back to a command line string of characters with no imposed grouping.

For most other commands, you would be able to pass them either
as one -L1 argument or two -L and 1 arguments and also be able
to combine more than one option in a single argument as in
-xyL1 (assuming -x and -y are options that don't take
arguments, are flags/boolean).

Yeah, as I was saying, it does seem that 'tree' is very crabby. Why don't the GNU people iron these things out?






Messages sorted by: Reverse Date, Date, Thread, Author