Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: array with newlines preserved as literal text
- X-seq: zsh-users 26452
- From: Ray Andrews <rayandrews@xxxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: array with newlines preserved as literal text
- Date: Tue, 2 Feb 2021 15:31:06 -0800
- Archived-at: <https://zsh.org/users/26452>
- Archived-at: <http://www.zsh.org/sympa/arcsearch_id/zsh-users/2021-02/36596ab3-14b6-da57-e40b-3e66d9ffbb5a%40eastlink.ca>
- In-reply-to: <CAH+w=7bAZKawy_BfTMGzuCm96NB=gDA6R-K9aZBd4N+uOOT-=A@mail.gmail.com>
- List-id: <zsh-users.zsh.org>
- References: <52dba8e4-2538-7c96-ecd5-66e017ab2b8e@eastlink.ca> <CAH+w=7bAZKawy_BfTMGzuCm96NB=gDA6R-K9aZBd4N+uOOT-=A@mail.gmail.com>
On 2021-02-02 12:25 p.m., Bart Schaefer wrote:
On Tue, Feb 2, 2021 at 11:16 AM Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
I'm curious why you want to save this in the form of a command to be
eval'd rather than just save the argument string?
Complicated. It goes back to my first bitch with zsh, namely not being
able to capture the literal invocation of a function (along with it's
tail) unexpanded, just as you'd see in history. (History would work
fine except for the fact that several commands can end up on the same
line.) Basically my wrappers do some heavy duty massaging of output and
both for debugging and or for modification it's good to be able to
recall the actual commands executed. My function '_execute' does that,
it calls 'eval' but does other stuff too like store to history. Here's
a sample:
$ l ,Hs c,* # 'l' wraps 'ls' and colorizes and formats the output as
I like:
LISTING of "c,*": all file types, INsensitive. Sorting upside down by:
File Size:
10746 [2020-12-20--14:48] c,34
11168 [2020-12-27--10:39] c,35,localized help
11219 [2020-12-27--10:45] c,36
11348 [2020-12-28--13:30] c,38,delete deleted directories
11428 [2020-12-28--10:46] c,37,trivial
11665 [2020-12-28--16:17] c,39
11833 [2020-12-28--16:48] c,40,misc
13253 [2020-12-28--19:48] c,41,polishing
13376 [2020-12-28--20:09] c,42,messages improved
13383 [2020-12-29--07:02] c,43,before improved cd
14045 [2021-01-31--11:08] c,55,more one line bugs
14053 [2021-01-31--13:05] c,56,trivial edits
14156 [2021-01-30--10:48] c,54,rationalize switches
14184 [2021-01-24--20:47] c,52,interim
14186 [2021-01-29--06:17] c,53,more sky trouble. big code purge
14494 [2020-12-30--06:17] c,44,better cd to incomplete name
14925 [2020-12-30--11:55] c,47,massive edit old code purged
15493 [2020-12-30--09:41] c,45,working huge edit
15741 [2021-01-31--10:48] c,48,good old Sky above was truncated
16080 [2020-12-30--10:06] c,46,bad
16394 [2021-01-07--08:49] c,50
Items found: 1
Total bytes in this directory: 2.9M
Total including subdirs: 15M
... the ',H' switch stores the actual working code to history. Hit the
up arrow and:
$ ls -AFrGgdS --time-style='+[%F--%H:%M]' --group-directories-first
--color=always (#i)c,* 2> /dev/null | sed -r "s|^(.{10} [[:digit:]]
)| |" | egrep -v '^total' | egrep -i --color=always "^|] c,*" | sed -r
"s/\x1b\[01;31m\x1b\[K\] /\] \x1b\[01;31m\x1b\[K/g"
... hit ENTER and exactly the same output occurs. Or modify to suit, or
perhaps to chase down a bug.
But it requires execution to be put off, thus the need for an eval
contained within '_execute'. Meanwhile let's see what Roman has for me.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author