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

Re: protect spaces and/or globs



On 2021-02-10 8:29 a.m., Peter Stephenson wrote:

As always, that depends what you're actually doing, which is a superset of
what you're telling us you're doing,
It's hard to put it briefly and still accurately.  I went down a certain path when I first got involved and it might not have been the right path nevertheless it has a certain power.  My wrappers evolve and evolve with more and more filtering and coloring
and columnizing and massaging and end up with some monstrous actual command
strings to execute.  By being able to recall the actual command, I can edit it to find some bug very quickly.  My function assembled: " grep-i -- arg arg " when what was wanted was: " grep -i -- arg arg " . Once I know where the bug is, I can figure out where it came from in my function very quickly.   So I assemble my string, save it to history (optionally) and then eval it to fire it off.  Up arrow, and voila!  I have the
guts of what my function did, available to tweak.  So:

9 /aWorking/Zsh/Source/Wk 3 $ l ,H l,*

LISTING of "l,*": all file types, INsensitive. Sorting upside down by: Mod. Time:

 11434 [2021-01-07--08:49] l,6,NO H
 10516 [2021-01-07--08:49] l,4,BUG and case now insensitive
...
 15988 [2021-02-03--20:06] l,51,colorize all matches if leading wildcard
 15614 [2021-02-04--16:34] l,52,bug with totals

Items found: 52
Total bytes in this directory: 3.5M
Total including subdirs: 16M

... and how did that actually happen?  " ,H " orders a write to history so up arrow and:

9 /aWorking/Zsh/Source/Wk 3 $ ls -AFrGgdt --time-style='+[%F--%H:%M]' --group-directories-first --color=always  (#i)l,* 2> /dev/null   | sed -r "s|^(.{10} {1,2}[[:digit:]]{1,2} )| |"  | egrep -v '^total' | egrep -i --color=always "^|] l,*"                      | sed -r "s/\x1b\[01;31m\x1b\[K\] /\] \x1b\[01;31m\x1b\[K/g"

... that's the actual guts of the thing.  No, I'm not insane, I just like color, prefer to remove all the permissions stuff since it it irrelevant to me, etc.  But the whole show requires the whole command to exist as a string so it can be saved and thus it needs 'eval' to fire it off ... unless I'm mistaken.

If that makes any sense.  It all works quite fine but there are these quoting issues now and then.








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