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

expansion in conditional expression patterns




Consider this expression:

% if [[ 1 != <1-5> ]]; then print outside; fi
% if [[ 1 != <2-5> ]]; then print outside; fi
outside

But what if I want 5 to be a variable?

% limit=5
% if [[ 1 != <2-$limit> ]]; then print outside; fi
zsh: parse error: condition expected: 1

The manual:

Normal shell expansion is performed on the file, string and pattern arguments, but the result of each expansion is constrained to be a sin- gle word, similar to the effect of double quotes. However, pattern metacharacters are active for the pattern arguments; the patterns are the same as those used for filename generation, see zshexpn(1), but there is no special behaviour of `/' nor initial dots, and no glob
 qualifiers are allowed.

What part of this do I misunderstand?

Thanks for help!


Sebastian



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