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

Re: 'case' pattern matching bug with bracket expressions



On May 14,  4:55pm, Peter Stephenson wrote:
}
} It occurs to me that other shells will treat whitespace as ending a
} pattern for syntactic reasons, even if logically it can't:
} 
} [[ ' ' = [ ] ]]
} 
} works in zsh, but is a parse error in bash.

Right, and your patch in 35131 does not change that.  Arguably (in POSIX
mode, at least) the space should need to be escaped?

Even in bash the space can be left unescaped in some contexts; e.g.

schaefer@burner:~$ var=' '
schaefer@burner:~$ echo ${var//[ ]/foo}
foo

I guess it's a quoting thing:

schaefer@burner:~$ case " " in ( [" "] ) echo OK;; esac
OK

In ${...} the space is already implicitly quoted, but quoting it again
doesn't change anything:

schaefer@burner:~$ echo ${var//[" "]/foo}
foo
schaefer@burner:~$ var='"'
schaefer@burner:~$ echo ${var//[" "]/foo}
"

Anyway, this is one of the rare cases where I don't think it would be
terrible if this changed in native zsh mode too, as long as the quoted
examples, like the above, don't break.

-- 
Barton E. Schaefer



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