zsh-users
 help / color / mirror / code / Atom feed
* Case statement with ";|" [not implemented]
@ 2007-01-18 19:53 Gerald Lai
  2007-01-19  4:52 ` Bart Schaefer
  0 siblings, 1 reply; 3+ messages in thread
From: Gerald Lai @ 2007-01-18 19:53 UTC (permalink / raw)
  To: zsh-users

[-- Attachment #1: Type: text/plain, Size: 1216 bytes --]

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

[-- Attachment #2: Type: text/html, Size: 2558 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-01-19 12:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-01-18 19:53 Case statement with ";|" [not implemented] Gerald Lai
2007-01-19  4:52 ` Bart Schaefer
2007-01-19 12:01   ` Peter Stephenson

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).