KornShell Boolean Conditional Logic KornShell Boolean Conditional Logic shell shell

KornShell Boolean Conditional Logic


test and [ are the same thing. You need to get rid of the test command from your if statement, so it would look like this:

if $catme; then    some commandsfi

Type man test to get more info.

For example:

$ v=true  $ $v$ if $v; then>   echo "PRINTED"> fiPRINTED$ v=false$ if $v; then>   echo "PRINTED"> fi$ 


You can also try the trial and error method:

if [[ true ]]; then echo +true; else echo -false; fi+trueif [[ false ]]; then echo +true; else echo -false; fi+trueif [[ 0 ]]; then echo +true; else echo -false; fi+trueif [[ -1 ]]; then echo +true; else echo -false; fi+trueif (( -1 )); then echo +true; else echo -false; fi+trueif (( 0 )); then echo +true; else echo -false; fi-falseif (( 1 )); then echo +true; else echo -false; fi+trueif [[ true == false ]]; then echo +true; else echo -false; fi-falseif [[ true == true ]]; then echo +true; else echo -false; fi+trueif true; then echo +true; else echo -false; fi+trueif false; then echo +true; else echo -false; fi-false


Try [[ $catme == true ]] instead.

Or better still, gahooa's answer is pretty good.