zsh-workers
 help / color / mirror / code / Atom feed
* Quoting =(command)
@ 2006-03-26 16:37 ` A. Wik
  2006-03-26 18:37   ` Peter Stephenson
  0 siblings, 1 reply; 2+ messages in thread
From: A. Wik @ 2006-03-26 16:37 UTC (permalink / raw)
  To: Zsh hackers list


How do I quote the =(<commands>) syntax that returns a the
name of a temporary file containing the output of <commands>?

Example: star is an improved tar program that can take a list of
files to archive through the =<list> command-line parameter - in
this case, the list is to be generated by the find program:
    # star -cv f=etc-bak.tar -C / list==(cd / ; find ./etc -newer /tmp/mtime.ref)
    zsh: parse error near `)'

I briefly thought I had found a solution:
    # echo $(echo =(cd / ; find ./etc -newer /tmp/mtime.ref)) 
    /tmp/zshonheGz

However:
    # cat $(echo =(cd / ; find ./etc -newer /tmp/mtime.ref))
    cat: /tmp/zshioLLt3: No such file or directory

-aw


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Quoting =(command)
  2006-03-26 16:37 ` Quoting =(command) A. Wik
@ 2006-03-26 18:37   ` Peter Stephenson
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Stephenson @ 2006-03-26 18:37 UTC (permalink / raw)
  To: Zsh hackers list

[This is probably more in the line of zsh-users.]

"A. Wik" wrote:
> 
> How do I quote the =(<commands>) syntax that returns a the
> name of a temporary file containing the output of <commands>?
> 
> Example: star is an improved tar program that can take a list of
> files to archive through the =<list> command-line parameter - in
> this case, the list is to be generated by the find program:
>     # star -cv f=etc-bak.tar -C / list==(cd / ; find ./etc -newer /tmp/mtime.
> ref)
>     zsh: parse error near `)'

Do you mean star takes a *file containing* the list of files to archive?
If it was just the list itself, then you would use "$(...)".

If you really do want a file name containing the list, I think you're in
trouble because the code seems to indicate =(...) only works at the
start of the word: as the manual says, a full command argument must be
in that form.

You can keep the scoping benefit (i.e. the temporary lasts as long as it
needs to and is then deleted) using something like:

star_list() {
  star -cv f=$1 -c / list=$2
}
star_list etc-bak.tar =(cd / ; find ./etc -n newer /tmp/mtime.ref)

By the way, you can get rid of find, too:

ntr() { [[ $REPLY -nt /tmp/mtime.ref ]] }
star_list etc-bak.tar =(cd /; print -l ./etc/**/*(+ntr))

With older versions of the shell, you need e:ntr: instead of +ntr.

-- 
Peter Stephenson <p.w.stephenson@ntlworld.com>
Web page still at http://www.pwstephenson.fsnet.co.uk/


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-03-26 18:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <aw@aw.gs>
2006-03-26 16:37 ` Quoting =(command) A. Wik
2006-03-26 18:37   ` Peter Stephenson

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).