Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8461225
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T13:49:17+00:00 2026-06-10T13:49:17+00:00

In popular imperative languages, switch statements generally fall through to the next level once

  • 0

In popular imperative languages, switch statements generally “fall through” to the next level once a case statement has been matched.

Example:

int a = 2;
switch(a)
{
   case 1:
      print "quick ";
   case 2: 
      print "brown ";
   case 3: 
      print "fox ";
      break;
   case 4:
      print "jumped ";
}

would print “brown fox”.

However the same code in bash

A=2
case $A in
2)
  echo "QUICK"
  ;&
2)
  echo "BROWN"
  ;&
3)
  echo "FOX"
  ;&
4)
  echo "JUMPED"
  ;&
esac

only prints “BROWN”

How do I make the case statement in bash “fall through” to the remaining conditions like the first example?

(edit: Bash version 3.2.25, the ;& statement (from wiki) results in a syntax error)

running:

test.sh:

#!/bin/bash
A=2
case $A in
1)
  echo "QUICK"
  ;&
2)
  echo "BROWN"
  ;&
3)
  echo "FOX"
  ;&
esac

Gives:

./test.sh: line 6: syntax error near unexpected token ;' ./test.sh:
line 6:
;&’

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T13:49:19+00:00Added an answer on June 10, 2026 at 1:49 pm

    The ;& and ;;& operators were introduced in bash 4.0, so if you want to stick with a five year old version of bash, you’ll either have to repeat code, or use ifs.

    if (( a == 1)); then echo quick; fi
    if (( a > 0 && a <= 2)); then echo brown; fi 
    if (( a > 0 && a <= 3)); then echo fox; fi
    if (( a == 4)); then echo jumped; fi
    

    or find some other way to achieve the actual goal.

    (On a side note, don’t use all uppercase variable names. You risk overwriting special shell variables or environment variables.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Some popular languages like Python and Ruby have native, JVM and .Net CLR implementations.
What programming language has short and beautiful grammars (in EBNF)? Some languages are easer
Some popular programming languages use month numbering which is off by 1 -- JavaScript
A popular text editor has the following find in files feature that opens in
37signals has some popular online web apps. There are some free alternatives (mostly PHP)
I know it is popular to hate on IDEs, but I've been using rubymine
Are there any popular Mysql rss feeds you guys can recommend? IBM has random
What popular programming languages were intentionally designed from the beginning to have both ===
MongoDB has two popular ORMs for Rails: MongoID and MongoMapper. Are there CouchDB ORM:s
This popular Stack Overflow question explained why CSS selectors are parsed right to left.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.