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

Re: expansion in conditional expression patterns



On Oct 13,  1:42pm, Sebastian Stark wrote:
}
} On 13.10.2009, at 11:07, Peter Stephenson wrote:
} 
} > On Mon, 12 Oct 2009 19:51:14 +0200
} > Sebastian Stark <seb-zsh@xxxxxxxxxxx> wrote:
} >> % limit=5
} >> % if [[ 1 != <2-$limit> ]]; then print outside; fi
} >> zsh: parse error: condition expected: 1
} >>
} > Logically this ought to work: parameter substitution is performed
} > before pattern matching or globbing. However, "<" is rather
} > overloaded and when the expression is parsed the shell only decides
} > it's a numeric glob if the expression is in the strict form with
} > digits.
} 
} I just did this:
} 
}    if [[ ! ( ($cmdnum -ge 1) && ($cmdnum -le $limit) ) ]]

That's probably better in this circumstance, but in the event that you
really do need to use the glob pattern, ${~:-<2-$limit>} will force
the correct parse.

schaefer<512> limit=5; touch {1..6}; print ${~:-<2-$limit>}
2 3 4 5



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