- I'm trying to write a script to check whether my input is correct. If I use a script as below, I cannot get the correct data.
#! /bin/csh
set input_tmp = $1
set input = `echo "$input_tmp" | tr '[a-z]' '[A-Z]'`
echo "Your input must be AAA | BBB"
if ("$input" != "AAA" || "$input" != "BBB") then
echo "$input : FAIL"
else
echo "$input : PASS"
endif
When I source and add the input, the result is:
%source check AAA
Your input must be AAA | BBB
AAA : FAIL
- If I try to replace "!=" to "==". The script is ok.
#! /bin/csh
set input_tmp = $1
set input = `echo "$input_tmp" | tr '[a-z]' '[A-Z]'`
echo "Your input must be AAA | BBB"
if ("$input" == "AAA" || "$input" == "BBB") then
echo "$input : PASS"
else
echo "$input : FAIL"
endif
When I try to test. It's ok.
% source check2 AAA
Your input must be AAA | BBB
AAA : PASS
% source check2 CCC
Your input must be AAA | BBB
CCC : FAIL
---
I don't know why Case 1 does not work because I maybe need to use Case 1 in some cases Please help to review.
Aucun commentaire:
Enregistrer un commentaire