zsh-workers
 help / color / mirror / code / Atom feed
* Re: Manpage improvement
       [not found] <Pine.GSO.4.02.9809271745400.19479-100000@astmatix.ida.liu.se>
@ 1998-09-28 14:00 ` Peter Stephenson
  1998-09-28 16:34   ` Bart Schaefer
  0 siblings, 1 reply; 2+ messages in thread
From: Peter Stephenson @ 1998-09-28 14:00 UTC (permalink / raw)
  To: zsh-workers; +Cc: johsu650

> x11amp "${(@f)$(locate Argentina|grep .mp3)}"
>
> I hope this might qualify as an example to spice up future zsh
> manpages.

Here's a change to the manual source which should make this sort of
thing a little clearer.  (You only need the (@) flag with array words, not
when splitting a single value into words.)

*** Doc/Zsh/expn.yo.par	Thu Jul  9 12:09:43 1998
--- Doc/Zsh/expn.yo	Mon Sep 28 15:53:57 1998
***************
*** 301,308 ****
  If a tt(${)...tt(}) type parameter expression or a tt($LPAR())...tt(RPAR())
  type command
  substitution is used in place of var(name) above, it is substituted first
! and the result is used as it were the value of var(name).
  
  If the opening brace is directly followed by an opening parenthesis,
  the string up to the matching closing parenthesis will be taken as a
  list of flags.  Where arguments are valid, any character, or the
--- 301,313 ----
  If a tt(${)...tt(}) type parameter expression or a tt($LPAR())...tt(RPAR())
  type command
  substitution is used in place of var(name) above, it is substituted first
! and the result is used as it were the value of var(name).  Thus it is
! possible to perform nested operations:  tt(${${foo#head}%tail})
! prints the variables tt($foo) after deleting both the head and tail from
! the value.  The form with tt($LPAR())...tt(RPAR()) is often useful in
! combination with the flags described next; see the example below.
  
+ subsect(Flags)
  If the opening brace is directly followed by an opening parenthesis,
  the string up to the matching closing parenthesis will be taken as a
  list of flags.  Where arguments are valid, any character, or the
***************
*** 414,419 ****
--- 419,435 ----
  Include the length of the match in the result.
  )
  enditem()
+ subsect(Example)
+ The flag tt(f) is useful to split a double-quoted substitution line by
+ line.  For example,
+ 
+ nofill(var(cmd) tt("${)tt(LPAR()f)tt(RPAR()$)tt(LPAR()<)var(file)tt(RPAR()}"))
+ 
+ will substitue the contents of var(file) divided so that one line is
+ supplied per argument to var(cmd).  Compare this with the effect of
+ tt($)tt(LPAR()<)var(file)tt(RPAR()) alone, which divides the file
+ up by words, or the same inside double quotes, where the entire
+ contents of the file are passed as a single argument.
  texinode(Command Substitution)(Arithmetic Expansion)(Parameter Expansion)(Expansion)
  sect(Command Substitution)
  cindex(command substitution)

-- 
Peter Stephenson <pws@ibmth.df.unipi.it>       Tel: +39 050 844536
WWW:  http://www.ifh.de/~pws/
Gruppo Teorico, Dipartimento di Fisica
Piazza Torricelli 2, 56100 Pisa, Italy


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

* Re: Manpage improvement
  1998-09-28 14:00 ` Manpage improvement Peter Stephenson
@ 1998-09-28 16:34   ` Bart Schaefer
  0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 1998-09-28 16:34 UTC (permalink / raw)
  To: zsh-workers

On Sep 28,  4:00pm, Peter Stephenson wrote:
} Subject: Re: Manpage improvement
}
} > x11amp "${(@f)$(locate Argentina|grep .mp3)}"
} >
} > I hope this might qualify as an example to spice up future zsh
} > manpages.
} 
} Here's a change to the manual source which should make this sort of
} thing a little clearer.

The first hunk of Peter's patch fails if you've applied my collection
of man page patches, posted a couple of months ago over the course of
several weeks.  Here's a patch that will apply on top of my previous
patches.

I've taken the liberty of changing

    prints the variables tt($foo) after deleting both the head and tail
    from the value.

to

    substitues the value of tt($foo) with both tt(head) and tt(tail)
    deleted.

My previous patch had already added a subsection "Parameter Expansion
Flags" where Peter's added "Flags".

If you tried to apply Peter's patch and got one failed hunk and one
succeeded hunk, you can delete the second hunk from the patch below
and apply only the first hunk.

Index: Doc/Zsh/expn.yo
===================================================================
--- expn.yo	1998/08/27 15:56:33	1.6
+++ expn.yo	1998/09/28 16:32:22
@@ -450,7 +450,11 @@
 If a tt(${)...tt(}) type parameter expression or a
 tt($LPAR())...tt(RPAR()) type command substitution is used in place of
 var(name) above, it is substituted first and the result is used as if
-it were the value of var(name).
+it were the value of var(name).  Thus it is
+possible to perform nested operations:  tt(${${foo#head}%tail})
+substitues the value of tt($foo) with both tt(head) and tt(tail)
+deleted.  The form with tt($LPAR())...tt(RPAR()) is often useful in
+combination with the flags described next; see the example below.
 
 subsect(Parameter Expansion Flags)
 cindex(parameter expansion flags)
@@ -567,6 +571,17 @@
 Include the length of the match in the result.
 )
 enditem()
+subsect(Example)
+The flag tt(f) is useful to split a double-quoted substitution line by
+line.  For example,
+
+nofill(var(cmd) tt("${)tt(LPAR()f)tt(RPAR()$)tt(LPAR()<)var(file)tt(RPAR()}"))
+
+will substitue the contents of var(file) divided so that one line is
+supplied per argument to var(cmd).  Compare this with the effect of
+tt($)tt(LPAR()<)var(file)tt(RPAR()) alone, which divides the file
+up by words, or the same inside double quotes, where the entire
+contents of the file are passed as a single argument.
 texinode(Command Substitution)(Arithmetic Expansion)(Parameter Expansion)(Expansion)
 sect(Command Substitution)
 cindex(command substitution)

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


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

end of thread, other threads:[~1998-09-28 16:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <Pine.GSO.4.02.9809271745400.19479-100000@astmatix.ida.liu.se>
1998-09-28 14:00 ` Manpage improvement Peter Stephenson
1998-09-28 16:34   ` 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).