On Thu, Sep 25, 2025 at 10:32:10AM -0600, Stan Marsh wrote:
[...]
>
>  $ case 1 in 1) ls ksjdfh && :; esac
> ls: cannot access 'ksjdfh': No such file or directory

This example demonstrates a quirk in the case command that piqued my interest:-

The last *list* in a case command may be terminated by a single ';', but all
other lists must be terminated by ';;'.

These are accepted:-
| $ case 2 in 1) echo test1;; 2) echo test2; echo foo; esac
| test2
| foo
| $ case 1 in 1) echo test1;; 2) echo test2; echo foo; esac
| test1

This is not accepted:-
| $ case 1 in 1) echo test1; 2) echo test2; echo foo; esac
| -bash: syntax error near unexpected token `)'

Does this just "happen to work"?

Cheers ... Duncan.

  • "set -e&quo... Stan Marsh
    • Re: "s... Lawrence Velázquez
    • Re: "s... Duncan Roe via Bug reports for the GNU Bourne Again SHell
      • Re: &qu... Lawrence Velázquez
        • Sou... Duncan Roe via Bug reports for the GNU Bourne Again SHell

Reply via email to