zsh-users
 help / color / mirror / code / Atom feed
* Re: Quoting =(command)
       [not found] <200603261837.k2QIbOow004386@pwslaptop.csr.com>
@ 2006-03-26 20:55 ` Bart Schaefer
  2006-03-26 20:58   ` Bart Schaefer
  2006-05-15 15:17 ` A. Wik
  1 sibling, 1 reply; 4+ messages in thread
From: Bart Schaefer @ 2006-03-26 20:55 UTC (permalink / raw)
  To: zsh-users

On Mar 26,  7:37pm, Peter Stephenson wrote:
}
} [This is probably more in the line of zsh-users.]

[Redirected there.]

} "A. Wik" wrote:
} >     # star -cv f=etc-bak.tar -C / list==(cd / ; find ./etc ...)
} >     zsh: parse error near `)'
} 
} 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.

A real zsh parameter assignment works, though:

  list==(cd /; print -l ./etc/**/*(+ntr)) eval 'star -cv list=$list -C /'
 


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

* Re: Quoting =(command)
  2006-03-26 20:55 ` Quoting =(command) Bart Schaefer
@ 2006-03-26 20:58   ` Bart Schaefer
  0 siblings, 0 replies; 4+ messages in thread
From: Bart Schaefer @ 2006-03-26 20:58 UTC (permalink / raw)
  To: zsh-users

On Mar 26, 12:55pm, Bart Schaefer wrote:
}
} A real zsh parameter assignment works, though:

Which just gave me another idea.

star -cv f=/etc-bak.tar list=${:-=(cd /; print -l ./etc/**/*(+ntr))} -C /


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

* Re: Quoting =(command)
       [not found] <200603261837.k2QIbOow004386@pwslaptop.csr.com>
  2006-03-26 20:55 ` Quoting =(command) Bart Schaefer
@ 2006-05-15 15:17 ` A. Wik
  2006-05-15 16:10   ` Bart Schaefer
  1 sibling, 1 reply; 4+ messages in thread
From: A. Wik @ 2006-05-15 15:17 UTC (permalink / raw)
  Cc: Zsh users


(Look, it's not even a month old ;)

On Sun, 26 Mar 2006, Peter Stephenson wrote:

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

I'm inclined to agree - however, not considering the point
of view of posting at the time of reading the subscription 
instructions, I interpreted them as "just forget zsh-users
and join zsh-workers for the full range of content"... (but
I'll try it now.)

> "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 "$(...)".

Yes, I did mean the former - the argument of "list=" is always
a file name... or as I discovered later, a dash (-) for reading
from stdin, and which was, of course, the perfect solution to my
problem.

Although the lone dash is interpreted similary by many other
programs too, a solution internal to the shell is certain
to come in handy some day... and Bart's second reply suggests
a workaround about as concise as can reasonably be expected:

	star -cv f=bak.tar list=${:-=(commands...)}

Perhaps it should be mentioned or at least hinted at in the 
context of the =() construct, as that was where I started
looking.   Considering that even you as the lead developer
managed to miss it, the odds may not be in favour of the
casual explorer doing so... but at least hindsight seems
to help:

       ${name:-word}
	      If name is set and is non-null then substitute
	      its value; otherwise substitute word. If	name
	      is missing, substitute word.

-aw


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

* Re: Quoting =(command)
  2006-05-15 15:17 ` A. Wik
@ 2006-05-15 16:10   ` Bart Schaefer
  0 siblings, 0 replies; 4+ messages in thread
From: Bart Schaefer @ 2006-05-15 16:10 UTC (permalink / raw)
  To: Zsh users

On May 15,  3:17pm, A. Wik wrote:
}
} On Sun, 26 Mar 2006, Peter Stephenson wrote:
} 
} > [This is probably more in the line of zsh-users.]
} 
} I'm inclined to agree - however, not considering the point
} of view of posting at the time of reading the subscription 
} instructions, I interpreted them as "just forget zsh-users
} and join zsh-workers for the full range of content"... (but
} I'll try it now.)

It's more a matter of where it gets archived.  zsh-users posts are
forwarded to zsh-workers subscribers, but they are not archived with
the zsh-workers material -- and obviously zsh-workers stuff is not
archived with zsh-users.  So someone searching for this answer after
the fact is better served if it is in the zsh-users archive.

} a workaround about as concise as can reasonably be expected:
} 
} 	star -cv f=bak.tar list=${:-=(commands...)}
} 
} Perhaps it should be mentioned or at least hinted at in the 
} context of the =() construct, as that was where I started
} looking.

I think this is more an FAQ than something for the base documentation.

The whole idea of using ${:-word} with nothing to the left of the colon
is an obscure zsh trick.  It only works because of zsh's rules for
parsing nested expansions; in other shells you get "bad substitution".

I don't think the process substitition context is the right place to
write about this, as it is only a subset of a more general "problem."
Wanting a generated file name as as a substring of a longer argument
word is a case that requires special handling no matter how the file
name is being generated.  E.g., I'm sure you would not have expected

    star -cv f=*.tar list=*.out

to work.  In this respect list==(...) is no different.

-- 


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

end of thread, other threads:[~2006-05-15 16:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <200603261837.k2QIbOow004386@pwslaptop.csr.com>
2006-03-26 20:55 ` Quoting =(command) Bart Schaefer
2006-03-26 20:58   ` Bart Schaefer
2006-05-15 15:17 ` A. Wik
2006-05-15 16:10   ` 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).