0

I tried this and failed. Does case statements exist in termux?

#!/data/data/com.termux/files/usr/bin/bash
case in "$1"
    start)
            echo 'var1'
            ;;
    stop)
            echo 'var2'
            ;;
esac
2

Termux does indeed support case, but your syntax is incorrect. This, instead, works.

case "$1" in
 start)
  echo 'var1'
  ;;

 stop)
  echo 'var2'
  ;;
esac

Adding a blank line between the start) and stop) blocks is just a stylistic choice.

  • Tnx. Got it. Where I can generally investigate about termux borders: what is supported and what - not. – Josef Klimuk Feb 15 '18 at 7:49
  • 1
    @JosefKlimuk Being Termux's default shell Bash, you can assume that all of the builtins and shell commands you would be able to call during a Bash session on a Linux machine be working. If what concerns you are what packages are able to be installed, either see the project's homepage, or directly ask its author, which maintains said packages. – Death Mask Salesman Feb 15 '18 at 12:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.