In a Bash script, I'd like to define a boolean variable y
to store the negated value of another boolean variable x
. The following script,
#!/bin/bash
x=true
y=$(( ! "${x}" ))
echo "${y}"
sets variable y
to 1. How can I change y
so it evaluates to false
instead?
y=$(case "$x" in true ) echo false ;; * ) echo "Unknown Value for x=$x" 1>&2 ; echo "nonesuch" ;; esac)
??true ; echo $?
means? If you want to use return values0
andnot 0
, you'll need to translate from the number to the text that you want. Good luck.