Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Case statement with ";|" [not implemented]
- X-seq: zsh-users 11130
- From: "Gerald Lai" <laigera@xxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Case statement with ";|" [not implemented]
- Date: Thu, 18 Jan 2007 11:53:04 -0800
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:mime-version:content-type; b=qypmxEQMbZU5epinGLYTakxkeqZOJwpSzqAeBTgahuOd4w7KQtIFz+L6Sx0p9A1gJ7JaaqoMwKEV6qdxSvypnjjuZ9dDn8pq31E6teTBHoZpIZ0FUNFCZM+S55wynKZ7i4cItk6tCv9Ckov5QrGYYY7YZ9vKnvbutVkPLLV6dPU=
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
Hello all :)
I'm new to the mailing list.
I'm trying to convert the (simplified) code below to a case statement structure:
===
if [[ $mycase -eq 0 ]]; then
echo "mycase is 0"
else
if [[ $mycase -eq 1 ]]; then
echo "mycase is 1"
else
echo "mycase is 2"
fi
echo "mycase is 1 or 2"
fi
===
And this is what I got:
===
case $mycase in
0)
echo "mycase is 0"
;;
1)
echo "mycase is 1"
;;
2)
echo "mycase is 2"
esac
if [[ $mycase -gt 0 ]] echo "mycase is 1 or 2"
===
My question is, shouldn't there be a way to do this:
===
case $mycase in
0)
echo "mycase is 0"
;;
1)
echo "mycase is 1"
;|
2)
echo "mycase is 2"
;|
*)
echo "mycase is 1 or 2"
esac
===
Note that ";|" provides an OR-like separator (as opposed to the AND-like ";&" separator) that goes through the case statements. However, unlike ";&", it checks $mycase against 1) and 2) instead of blindly executing case statements 1 & 2.
Wouldn't this be a good addition to ZSH? It certainly seems more useful than ";&".
--
Gerald Lai
Messages sorted by:
Reverse Date,
Date,
Thread,
Author