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

Re: how to?

On Aug 24, 11:56pm, Phil Pennock wrote:
} I didn't CC the list but instead made it a private reply.  Sorry for any
} offense caused -- I see that I didn't tone my wording well.

Oh, dear.  I completely missed that your message wasn't Cc'd to the list;
I thought I'd just accidentally hit "reply" instead of "replyall," so I
added the list back again.  You didn't cause any offense, nor did I have
any complaint about your tone; and I certainly didn't intend for my reply
to give such an impression.

Well, as we're here already ...

} > } Which leads to a question: how much hassle is it to have a glob modifier
} > } be able to duplicate the Simple Command which is calling it?
} > 
} > A glob modifier, just about impossible.  A precommand modifier or option,
} > perhaps.
} Are there sufficient hooks to allow this to be done as a module?

Definitely not for the option route, but maybe for a something that works
like a precommand modifier -- or, really, just a special builtin that
chops up the argument list and calls argv[0] repeatedly with subsets.

The trouble, of course, is that it's very difficult to generalize, such
that you know which arguments have to be kept with argv[0] on every call
and which can be split across calls.  You end up having to "invert" the
syntax, i.e., put the splittable args first, then some flag value (such
as "--"), and finally the command with its fixed args:

	zargs **/*.c -- ls -l

That could actually be written as a shell function:

	function zargs {
	    emulate -RL zsh
	    local command end=$argv[(i)--]
	    command=( $argv[end+1,-1] )
	    # Hmm: argv[end,-1]=() doesn't work ...
	    set -- $argv[1,end-1]
	    if ((ARGC == 0))
	    then $command
		while ((ARGC))
		    for (( end=ARGC; ${(c)#argv[1,end]} > 20480; end/=2 )) :
		    $command $argv[1,end]
		    shift $end

Aside to zsh-workers:  "emulate -R" should not reset the XTRACE option,
but it does ...

Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   

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