* xargs should be a builtin @ 2012-04-11 7:31 Dave Yost 2012-04-11 7:44 ` Frank Terbeck 0 siblings, 1 reply; 8+ messages in thread From: Dave Yost @ 2012-04-11 7:31 UTC (permalink / raw) To: zsh-workers Many’s the time I’ve wanted to use it to invoke a shell function. Surely others have felt this lack. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: xargs should be a builtin 2012-04-11 7:31 xargs should be a builtin Dave Yost @ 2012-04-11 7:44 ` Frank Terbeck 2012-04-11 10:06 ` Problems with zargs (Was: xargs should be a builtin) Stephane Chazelas 0 siblings, 1 reply; 8+ messages in thread From: Frank Terbeck @ 2012-04-11 7:44 UTC (permalink / raw) To: zsh-workers Dave Yost wrote: > Many’s the time I’ve wanted to use it to invoke a shell function. autoload -Uz zargs man zshcontrib | less -p '^ *zargs *\[' Regards, Frank ^ permalink raw reply [flat|nested] 8+ messages in thread
* Problems with zargs (Was: xargs should be a builtin) 2012-04-11 7:44 ` Frank Terbeck @ 2012-04-11 10:06 ` Stephane Chazelas 2012-04-11 16:15 ` Peter Stephenson 2012-04-12 23:05 ` Bart Schaefer 0 siblings, 2 replies; 8+ messages in thread From: Stephane Chazelas @ 2012-04-11 10:06 UTC (permalink / raw) To: Frank Terbeck; +Cc: zsh-workers 2012-04-11 09:44:48 +0200, Frank Terbeck: > Dave Yost wrote: > > Many’s the time I’ve wanted to use it to invoke a shell function. > > autoload -Uz zargs > man zshcontrib | less -p '^ *zargs *\[' [...] By the way, there seems to be some issues with zargs: ~$ zargs a b '' -- print -rl a b ~$ zargs a -- print -rl '' a ~$ zargs -e a '' print -rl a print -rl ~$ zargs --eof= a '' print -rl a ~$ echo $ZSH_VERSION $ZSH_PATCHLEVEL 4.3.17 Debian -- Stephane ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Problems with zargs (Was: xargs should be a builtin) 2012-04-11 10:06 ` Problems with zargs (Was: xargs should be a builtin) Stephane Chazelas @ 2012-04-11 16:15 ` Peter Stephenson 2012-04-12 9:28 ` Stephane Chazelas 2012-04-12 23:05 ` Bart Schaefer 1 sibling, 1 reply; 8+ messages in thread From: Peter Stephenson @ 2012-04-11 16:15 UTC (permalink / raw) To: Stephane Chazelas, zsh-workers On Wed, 11 Apr 2012 11:06:42 +0100 Stephane Chazelas <stephane.chazelas@gmail.com> wrote: > By the way, there seems to be some issues with zargs: > > ~$ zargs a b '' -- print -rl > a > b > ~$ zargs a -- print -rl '' > a > ~$ zargs -e a '' print -rl > a print -rl > ~$ zargs --eof= a '' print -rl > a It helps if everyone always says explicitly what the problem actually is, it saves lots of guesswork. I've come up with the following for the problems I understand, but I'm sure it could do with a bit more prodding. Index: Functions/Misc/zargs =================================================================== RCS file: /cvsroot/zsh/zsh/Functions/Misc/zargs,v retrieving revision 1.6 diff -p -u -r1.6 zargs --- Functions/Misc/zargs 14 Aug 2011 13:40:53 -0000 1.6 +++ Functions/Misc/zargs 11 Apr 2012 16:14:48 -0000 @@ -167,11 +167,11 @@ if [[ $eof == -(e|-eof) ]]; then ((end=A elif (( $#eof )); then end=$argv[(i)${eof##-(e|-eof=)}] else end=$argv[(i)--] fi -local -a args call command; command=( ${argv[end+1,-1]} ) +local -a args call command; command=( "${(@)argv[end+1,-1]}" ) if (( $opts[(I)-(null|0)] )) -then set -- ${(ps:\000:)argv[1,end-1]} -else set -- $argv[1,end-1] +then set -- "${(@ps:\000:)argv[1,end-1]}" +else set -- "${(@)argv[1,end-1]}" fi if [[ -n $command ]] @@ -187,7 +187,7 @@ local execute=' then print -u2 -r -- "$call" fi eval "{ - \$call + \"\${(@)call}\" } $bg"' local ret=0 analyze=' case $? in @@ -275,11 +275,11 @@ do ((ARGC)) || break for (( end=l; end && ${(c)#argv[1,end]} > s; end/=2 )) { } (( end > n && ( end = n ) )) - args=( $argv[1,end] ) + args=( "${(@)argv[1,end]}" ) shift $((end > ARGC ? ARGC : end)) if (( $#i )) - then call=( ${command/$i/$args} ) - else call=( $command $args ) + then call=( "${(@)command/$i/$args}" ) + else call=( "${(@)command}" "${(@)args}" ) fi if (( ${(c)#call} > s )) then -- Peter Stephenson <p.w.stephenson@ntlworld.com> Web page now at http://homepage.ntlworld.com/p.w.stephenson/ ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Problems with zargs (Was: xargs should be a builtin) 2012-04-11 16:15 ` Peter Stephenson @ 2012-04-12 9:28 ` Stephane Chazelas 2012-04-12 19:33 ` Peter Stephenson 0 siblings, 1 reply; 8+ messages in thread From: Stephane Chazelas @ 2012-04-12 9:28 UTC (permalink / raw) To: Peter Stephenson; +Cc: zsh-workers 2012-04-11 17:15:39 +0100, Peter Stephenson: > On Wed, 11 Apr 2012 11:06:42 +0100 > Stephane Chazelas <stephane.chazelas@gmail.com> wrote: > > By the way, there seems to be some issues with zargs: > > > > ~$ zargs a b '' -- print -rl > > a > > b > > ~$ zargs a -- print -rl '' > > a > > ~$ zargs -e a '' print -rl > > a print -rl > > ~$ zargs --eof= a '' print -rl > > a > > It helps if everyone always says explicitly what the problem actually > is, it saves lots of guesswork. Sorry about that. Wrote in a rush. > I've come up with the following for the problems I understand, but I'm > sure it could do with a bit more prodding. [...] Thanks. That seems to do the trick. May I knitpick: ~$ ''() echo X "$@" ~$ zargs 1 2 -- '' 1 2 ~$ zargs 1 2 -- '' '' X 1 2 --- zargs.old 2012-04-12 10:26:20.658633028 +0100 +++ /usr/share/zsh/functions/Misc/zargs 2012-04-12 10:27:20.709077765 +0100 @@ -174,7 +174,7 @@ else set -- "${(@)argv[1,end-1]}" fi -if [[ -n $command ]] +if (($#command)) then (( c = $#command - 1 )) else command=( print -r -- ) fi -- Stephane ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Problems with zargs (Was: xargs should be a builtin) 2012-04-12 9:28 ` Stephane Chazelas @ 2012-04-12 19:33 ` Peter Stephenson [not found] ` <CAH+w=7Z5pUmqxpURyHMA5FX3hMGoyQeYwbC1N7AO6Ow-D=P-gw@mail.gmail.com> 0 siblings, 1 reply; 8+ messages in thread From: Peter Stephenson @ 2012-04-12 19:33 UTC (permalink / raw) To: zsh-workers On Thu, 12 Apr 2012 10:28:22 +0100 Stephane Chazelas <stephane.chazelas@gmail.com> wrote: > --- zargs.old 2012-04-12 10:26:20.658633028 +0100 > +++ /usr/share/zsh/functions/Misc/zargs 2012-04-12 10:27:20.709077765 +0100 > @@ -174,7 +174,7 @@ > else set -- "${(@)argv[1,end-1]}" > fi > > -if [[ -n $command ]] > +if (($#command)) > then (( c = $#command - 1 )) > else command=( print -r -- ) > fi Thanks, I've committed it with that. -- Peter Stephenson <p.w.stephenson@ntlworld.com> Web page now at http://homepage.ntlworld.com/p.w.stephenson/ ^ permalink raw reply [flat|nested] 8+ messages in thread
[parent not found: <CAH+w=7Z5pUmqxpURyHMA5FX3hMGoyQeYwbC1N7AO6Ow-D=P-gw@mail.gmail.com>]
[parent not found: <20120413201325.64cfcd1f@pws-pc.ntlworld.com>]
* Re: Problems with zargs (Was: xargs should be a builtin) [not found] ` <20120413201325.64cfcd1f@pws-pc.ntlworld.com> @ 2012-04-14 17:01 ` Bart Schaefer 0 siblings, 0 replies; 8+ messages in thread From: Bart Schaefer @ 2012-04-14 17:01 UTC (permalink / raw) To: zsh-workers On Apr 13, 8:13pm, Peter Stephenson wrote: } Subject: Re: Problems with zargs (Was: xargs should be a builtin) } } On Fri, 13 Apr 2012 08:43:50 -0700 } Bart Schaefer <schaefer@brasslantern.com> wrote: } > One concern I have is that this may have changed behavior with respect } > to aliases. Does the first word of $call need to be unquoted? } } You're probably right that it's changed the behaviour. I'm not sure if } it was ever clear that aliases would be expanded, but there's no reason } not to restore it. I've just checked this against a few older versions of the shell and it appears that aliases were never expanded. So we can either leave it as it is, or change it to allow aliases in the command position ... but there is no way I can see to allow *global* aliases to expand without breaking quoting of the rest of the arguments. So perhaps the status quo is best maintained. -- Barton E. Schaefer ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Problems with zargs (Was: xargs should be a builtin) 2012-04-11 10:06 ` Problems with zargs (Was: xargs should be a builtin) Stephane Chazelas 2012-04-11 16:15 ` Peter Stephenson @ 2012-04-12 23:05 ` Bart Schaefer 1 sibling, 0 replies; 8+ messages in thread From: Bart Schaefer @ 2012-04-12 23:05 UTC (permalink / raw) To: zsh-workers On Apr 11, 11:06am, Stephane Chazelas wrote: } } By the way, there seems to be some issues with zargs: } } ~$ zargs a b '' -- print -rl } a } b } ~$ zargs a -- print -rl '' } a Hmm, empty strings are being collapsed out of $argv[end+1,-1] when it is assigned. I'm not remembering whether that's expected or something new. Patch below, though it probably needs some more test cases. } ~$ zargs -e a '' print -rl } a print -rl } ~$ zargs --eof= a '' print -rl } a This is actually the expected behavior. "zargs --help": --eof[=eof-str], -e[eof-str] Change the end-of-input-args string from "--" to eof-str. If given as --eof=, an empty argument is the end; as --eof or -e, with no (or an empty) eof-str, all arguments are input-args. Index: Functions/Misc/zargs =================================================================== retrieving revision 1.6 diff -c -r1.6 zargs --- zargs 20 Dec 2011 17:13:38 -0000 1.6 +++ zargs 12 Apr 2012 22:48:19 -0000 @@ -167,11 +167,11 @@ elif (( $#eof )); then end=$argv[(i)${eof##-(e|-eof=)}] else end=$argv[(i)--] fi -local -a args call command; command=( ${argv[end+1,-1]} ) +local -a args call command; command=( "${(@)argv[end+1,-1]}" ) if (( $opts[(I)-(null|0)] )) -then set -- ${(ps:\000:)argv[1,end-1]} -else set -- $argv[1,end-1] +then set -- "${(@ps:\000:)argv[1,end-1]}" +else set -- "${(@)argv[1,end-1]}" fi if [[ -n $command ]] @@ -187,7 +187,7 @@ then print -u2 -r -- "$call" fi eval "{ - \$call + ${(@qq)call} } $bg"' local ret=0 analyze=' case $? in @@ -205,7 +205,7 @@ if (( $opts[(I)-(-no-run-if-empty|r)] )) then return 0 else - call=($command) + call=( "${(@)command}" ) # Use "repeat" here so "continue" won't complain. repeat 1; do eval "$execute ; $analyze"; done return $ret @@ -275,11 +275,11 @@ ((ARGC)) || break for (( end=l; end && ${(c)#argv[1,end]} > s; end/=2 )) { } (( end > n && ( end = n ) )) - args=( $argv[1,end] ) + args=( "${(@)argv[1,end]}" ) shift $((end > ARGC ? ARGC : end)) if (( $#i )) - then call=( ${command/$i/$args} ) - else call=( $command $args ) + then call=( "${(@)command/$i/$args}" ) + else call=( "${(@)command}" "${(@)args}" ) fi if (( ${(c)#call} > s )) then ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2012-04-14 17:02 UTC | newest] Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2012-04-11 7:31 xargs should be a builtin Dave Yost 2012-04-11 7:44 ` Frank Terbeck 2012-04-11 10:06 ` Problems with zargs (Was: xargs should be a builtin) Stephane Chazelas 2012-04-11 16:15 ` Peter Stephenson 2012-04-12 9:28 ` Stephane Chazelas 2012-04-12 19:33 ` Peter Stephenson [not found] ` <CAH+w=7Z5pUmqxpURyHMA5FX3hMGoyQeYwbC1N7AO6Ow-D=P-gw@mail.gmail.com> [not found] ` <20120413201325.64cfcd1f@pws-pc.ntlworld.com> 2012-04-14 17:01 ` Bart Schaefer 2012-04-12 23:05 ` Bart Schaefer
Code repositories for project(s) associated with this public inbox https://git.vuxu.org/mirror/zsh/ This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).