Skip to content
Vidar Holen edited this page May 7, 2024 · 1 revision

BusyBox [[ .. ]] does not support glob matching. Use a case statement.

Problematic code:

#!/bin/busybox sh
if [[ $1 == https:* ]]
then
  echo "Using URL $1"
fi

Correct code:

#!/bin/busybox sh
case "$1" in
  https:*)
    echo "Using URL $1" 
    ;;
esac

Rationale:

You are using [[ .. ]] in BusyBox sh to match against a glob pattern. This is supported in Bash and Ksh, but not in BusyBox.

Rewrite the match to use a case statement instead.

Exceptions:

None.

Related resources:

  • Help by adding links to BashFAQ, StackOverflow, man pages, POSIX, etc!

ShellCheck

Each individual ShellCheck warning has its own wiki page like SC1000. Use GitHub Wiki's "Pages" feature above to find a specific one, or see Checks.

Clone this wiki locally