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

Re: $jobstates (Re: zsh: Strange feature with 'jobs' commmand)



Thomas Köhler wrote:

> ...
> 
> What I don't understand from "man zshparam":
> 
>        k      If  used  in  a  subscript on an associative array,
>               this flag causes the keys to be interpreted as pat­
>               terns,  and  returns  the  value  for the first key
>               found where exp is matched by the key.   This  flag
>               does  not work on the left side of an assignment to
>               an associative array element.  If used  on  another
>               type of parameter, this behaves like `r'.
> 
>        K      On  an  associative  array  this  is  like  `k' but
>               returns all values where  exp  is  matched  by  the
>               keys.   On  other  types of parameters this has the
>               same effect as `R'.
> 
> Why doesn't
>    ~> echo $jobstates[(K)*]
> return anything when [...]

You want (i):

  % echo $jobstates[(i)*]
  1 2 ...

With k and K the *keys* stored in the assoc (as opposed to the *exp*
given in the subscript) are used as patterns:

  % typeset -A type
  % type=('[a-zA-Z]' alpha '[0-9]' digit '[^a-zA-Z0-9]' other)
  % echo $type[(k)x] $type[(k)4] $type[(k).]
  alpha digit other


Bye
  Sven

-- 
Sven Wischnowsky                          wischnow@xxxxxxxxx



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