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

Re: (#m) and "case" alternation



2014-11-11 07:44:07 -0800, Bart Schaefer:
> On Nov 11, 12:54pm, Stephane Chazelas wrote:
> }
> } Some unexpected behaviour:
> } 
> } $ case abc in ((#m)a* | b*) echo $MATCH; esac
> 
> It shouldn't be unexpected, because it's documented:
> 
> m
>      Set references to the match data for the entire string matched;
>      this is similar to backreferencing and does not work in filename
>      generation.  THE FLAG MUST BE IN EFFECT AT THE END OF THE PATTERN,
>      i.e. NOT LOCAL TO A GROUP.
> 
> (all-caps mine).

OK, but in:

case abc in (#m)a* | b*) echo $MATCH; esac

my understanding was that we've got two patterns as that's the
"|" case alternation operator, not the "|" glob operator (with
which you can't have spaces on either side)..

Now, it looks like my understanding is wrong as

$ case bcd in ((#b)(a*) | (#b)(b*)) print -l "$match[@]";;esac

bcd

(bcd is in $match[2], so the second group of a *single*
pattern).

So thanks for the clarification, you may disregard my report.

-- 
Stephane



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