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

manual



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.





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