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

Re: xargs with zsh function



On 2021-01-18 9:18 p.m., Ray Andrews wrote:

I can't find any documentation of zargs which might help but behavior seems mysterious:

#!/usr/bin/zsh

autoload zargs
xzargs() { zargs  -n1 -t -- "${(f)$(read -d '' -E)}" -- "$@" }

typeset -g xinput=( 'mnt' 'rap' )

echo '\nfirst:'
eval "ls (#i)$xinput[1]"
eval "ls $xinput[2]"

function el ()
{
    echo '\nin function:'
    eval "ls (#i)$xinput[1]"
    eval "ls $xinput[2]"
}

echo '\nsecond:'
eval "ls (#i)$xinput[1]"
eval "ls $xinput[2]"

print "$xinput" | xzargs el

echo '\nthird:'
eval "ls (#i)$xinput[1]"
eval "ls $xinput[2]"

-----------------------------------------------
Output:
My system as she lies:

$ . test

first:
mnt
rap

second:
mnt
rap
el mnt rap

in function:
(eval):1: no matches found: (#i)mnt
rap

third:
mnt
rap

-----------------------------------------------
Now from clean shell:

h5--9-Debian1#  . test

first:
(eval):1: no matches found: (#i)mnt
rap

second:
(eval):1: no matches found: (#i)mnt
rap
el mnt rap

in function:
(eval):1: no matches found: (#i)mnt
rap

third:
(eval):1: no matches found: (#i)mnt
rap

-----------------------------------------------
Perhaps this has something to do with the call in 'el' being to a clean shell? Same sort of problem if I do this:

$ ls (#i)c
C  c

$ zsh -f
h5--9-Debian1# ls (#i)c
zsh: no matches found: (#i)c

...  But that's bedrock syntax no?  How can the clean shell not swallow it?  Anyway I'd like zargs to work within my environment as it is.






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