Bourne | Ash |  #!  | find | ARG_MAX | Shells | whatshell | portability | permissions | UUOC | ancient | - | ../Various | HOME
"$@" | echo/printf | set -e | test | tty defs | tty chars | $() vs ) | IFS | using siginfo | nanosleep | line charset | locale

The output of the type built-in for a function containing a case control structure

The output of "type" for a function also reports the content of its body.
For this purpose, the internal data structures are parsed again and a readable body is regenerated.
However, particularly the output for a "case...esac" control structure is printed incorrectly in many versions.

The following call

  f() {
      case W in 
      X|Y|Z) : ;;
      *)     : ;;
  type f

usually generates the following output for the body:

    case WZ | Y | X):;;*):;;
that is, the keywords "in" (including the surrounding blanks) and "esac" are missing. There's no data corruption, but the according statements for reassembling the output are just missing. As cosmetic difference, the order in the alternation is reversed.

Some implementations have been fixed, in different ways: