zsh-users
 help / color / mirror / code / Atom feed
* manual
@ 2022-12-20 22:41 Ray Andrews
  2022-12-21  0:43 ` manual Lawrence Velázquez
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Ray Andrews @ 2022-12-20 22:41 UTC (permalink / raw)
  To: Zsh Users

Daniel was interested in what I'd do with the 'set' man page.  It has a 
completely different flavor but:

'set' has too many uses:

1): set [+]
2): set {+|-}s [STRING] [STRING] ...
3): set {+|-}s -A [ARRAY_NAME] [VALUE]
4): set        +A [ARRAY_NAME] [VALUE]         # sorting not available 
with '+A'
5): set {+|-}OPTION_NAME
6): set +o
7): set -o
8): set {+|-}o [OPTION_NAME] [OPTION_NAME]  ... [--]

-----------------------------------------------------------------------------

1): set [+]:
Print all parameters.  If '+' is given print them without their values.

Where usable:
-s: Ascending sort of the input.
+s: Descending sort of the input.

2): set {+|-}s [STRING] [STRING] ... :
If no flags other than +s or -s are given then the arguments following 
'set' are assigned to the
positional parameters:

Example:

$ set one "two's company" three
$ print -l -- $1 $2 $3
one
two's company
three

3,4) An array will be set.  Notice there is no equal sign and the array 
members are NOT to be enclosed in parentheses.

3): set {+|-}s -A [ARRAY_NAME] [VALUE]:
ARRAY_NAME is set to VALUE, completely erasing any former contents:

4): set +A [ARRAY_NAME] [VALUE]:
ARRAY_NAME is overwritten by the new VALUE but not truncated if the new
VALUE is shorter than the old.

Example:

$ set +s -A ARRAY_NAME A B C  'dee licious'
$ typeset -p ARRAY_NAME
typeset -a ARRAY_NAME=( 'dee licious' C B A )  # Sort is descending

$ set +A ARRAY_NAME 1 2 3
$ typeset -p ARRAY_NAME
typeset -a ARRAY_NAME=( 1 2 3 A )              # Only three elements 
overwritten.

$ set +A ARRAY_NAME aaaa
$ typeset -p ARRAY_NAME
typeset -a ARRAY_NAME=( aaaa 2 3 A )           # Only first element 
overwritten.

The processing of arguments after -A or +A depends on whether the
option KSH_ARRAYS  is set.  If not set, all arguments following 
ARRAY_NAME are
treated as values for the array, regardless of their form -- zsh will 
attempt no
interpretation or expansion of the arguments.  But if the option is set, 
normal
option processing will occur and only 'regular' arguments are treated as 
values
for the array.  This means that:

$ set -A array -x -- foo

... sets array to '-x -- foo' if KSH_ARRAYS is not set, but sets the
array to 'foo' and turns on the option '-x' if it is set.

Note that 'typeset -A' is quite different from 'set -A'!  If you are 
copying an
associative array to another array you must do this:

$ typeset -A NEW_ARRAY
$ set -A NEW_ARRAY OLD_ARRAY

... otherwise NEW_ARRAY will not be associative.  Be warned.

5): set {+|-}[OPTION]
Turn on|off a single OPTION.

6): set +o:
Print all options and values formatted as commands.

7): set -o:
Print all options and values as a nice columnized display.

8): set {+|-}o [OPTION] [OPTION} ... [--]
Turn on|off the given OPTIONS.  If the list is followed by '--' the 
positional
parameters will be unset.



COMMENTS ON MAN PAGE:


               argFor the meaning of the other flags, see zshoptions(1).

WHAT OTHER FLAGS?


               For historical reasons, `set -' is treated as `set +xv' 
and `set - args' as
               `set +xv -- args' when in any other emulation mode than 
zsh's native mode.

DON'T KNOW WHAT TO DO WITH THAT.


               If the -A flag is specified, name is set to an array 
containing  the  given
               args;  if  no name is specified, all arrays are printed 
together with their
               values.

IS THAT CORRECT?  SEEMS TO ME ALL PARAMETERS ARE PRINTED NOT JUST ARRAYS.



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

end of thread, other threads:[~2022-12-22 14:21 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-20 22:41 manual Ray Andrews
2022-12-21  0:43 ` manual Lawrence Velázquez
2022-12-21  1:15   ` manual Ray Andrews
2022-12-21  1:44     ` manual Lawrence Velázquez
2022-12-21  4:15       ` manual Ray Andrews
2022-12-21  2:00 ` manual Daniel Shahaf
2022-12-21  4:12   ` manual Ray Andrews
2022-12-21  4:43   ` manual Bart Schaefer
2022-12-21 14:04     ` manual Ray Andrews
2022-12-22  6:31       ` manual Lawrence Velázquez
2022-12-22 14:20         ` manual Ray Andrews
2022-12-21  9:38   ` manual Lawrence Velázquez
2022-12-22  7:03 ` manual Lawrence Velázquez
2022-12-22 13:50   ` manual Ray Andrews

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