Skip to content

interp: case ignores the ;;& and ;& fallthrough terminators #1391

Closed

Description

@blairham

case parses bash's ;;& and ;& fallthrough terminators and then treats both as plain ;;.

$ gosh -c 'case ab in a*) echo one;;& *b) echo two;; esac'
one
$ bash -c 'case ab in a*) echo one;;& *b) echo two;; esac'
one
two

$ gosh -c 'case ab in a*) echo one;& *) echo two;; esac'
one
$ bash -c 'case ab in a*) echo one;& *) echo two;; esac'
one
two

Both parse without error, so the information is present in the AST and dropped at execution.

;;& is how a case classifies along several axes at once, e.g.

case "$file" in
  *.tar*)  untar=1 ;;&
  *.gz)    decomp=gunzip ;;
  *.bz2)   decomp=bunzip2 ;;
esac

For *.tar.gz this sets untar=1 and never selects a decompressor, so the script proceeds with an unset variable and the symptom appears elsewhere.

A silently-ignored terminator is worse than a parse error, which would at least stop on the line responsible. If honoring them is not desirable, rejecting them at parse time would be strictly better than the current behavior.

Found by a bash-vs-gosh differential sweep (128 snippets, each run direct and through eval) while integrating interp as the substrate of a shell. Reproduced on gosh@v3.13.2-0.20260813221317-a04df9f0d4b8 against bash 5.3.15 on darwin/arm64. Happy to send a PR if the direction looks right.

Activity

  1. added a commit that references this issue on Aug 22, 2026
    60421ca
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions