Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: expansion in conditional expression patterns
- X-seq: zsh-users 14493
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-users ml <zsh-users@xxxxxxxxxx>
- Subject: Re: expansion in conditional expression patterns
- Date: Tue, 13 Oct 2009 06:53:42 -0700
- In-reply-to: <D59FAFB2-6CC0-4BA6-92F9-698E08293E2C@xxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <F851A022-A342-41EE-9BC8-692B7E7D3025@xxxxxxxxxxx> <20091013100710.27e3c2fb@news01> <D59FAFB2-6CC0-4BA6-92F9-698E08293E2C@xxxxxxxxxxx>
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