Skip to content

Files

Latest commit

 

History

History
31 lines (20 loc) · 670 Bytes

SC2195.md

File metadata and controls

31 lines (20 loc) · 670 Bytes

Pattern: Unmatched case statement in shell script

Issue: -

Description

ShellCheck has detected that one of the patterns in a case statement will never match.

Often, this is due to mistakes in the case statement word that results in unintended literal characters.

Example of incorrect code:

case "$var " in      # Trailing space
  value) echo "Match"
esac

Here there's a trailing space that will prevent the match from ever succeeding.

Example of correct code:

case "${var}" in     # No trailing space
  value) echo "Match"
esac

Further Reading