Skip to content

Instantly share code, notes, and snippets.

@changx03
Created April 16, 2025 22:46
Show Gist options
  • Save changx03/e7a93bb2e0a277753af20400711618ab to your computer and use it in GitHub Desktop.
Save changx03/e7a93bb2e0a277753af20400711618ab to your computer and use it in GitHub Desktop.
bash example for matching 1 and 0
#!bin/bash
DEV=0
if [ "$#" -eq 1 ]; then
DEV="$1"
fi
# Expceting:
# bash ./test.bash 1 -> match
# bash ./test.bash "1" -> match
# bash ./test.bash 2 -> not match
# bash ./test.bash true -> not match
if [ "$DEV" = "1" ]; then
echo "MATCH! DEV is 1!"
else
echo "DEV is $DEV"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment