zsh-users
 help / color / mirror / code / Atom feed
From: "Gerald Lai" <laigera@gmail.com>
To: zsh-users@sunsite.dk
Subject: Case statement with ";|" [not implemented]
Date: Thu, 18 Jan 2007 11:53:04 -0800	[thread overview]
Message-ID: <e5d50bd20701181153j4ac7faeajd0ec871ea02af518@mail.gmail.com> (raw)

[-- 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 --]

             reply	other threads:[~2007-01-18 19:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-18 19:53 Gerald Lai [this message]
2007-01-19  4:52 ` Bart Schaefer
2007-01-19 12:01   ` Peter Stephenson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e5d50bd20701181153j4ac7faeajd0ec871ea02af518@mail.gmail.com \
    --to=laigera@gmail.com \
    --cc=zsh-users@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).