[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Quoting and string comparison
From: |
Jaan Vajakas |
Subject: |
Quoting and string comparison |
Date: |
Thu, 8 Feb 2018 14:05:00 +0100 |
Hi!
I noticed a weird behavior. Is it a bug?
Namely, why does
echo "$(for f in a b c; do if [[ \"$f\" > b ]]; then echo "$f > b"; else
echo "$f <= b"; fi; done)"
output
a <= b
b > b
c > b
?
I would have expected the same output as one of
echo "$(for f in a b c; do if [[ "$f" > b ]]; then echo "$f > b"; else echo
"$f <= b"; fi; done)"
echo "$(for f in a b c; do if [[ '"$f"' > b ]]; then echo "$f > b"; else
echo "$f <= b"; fi; done)"
This happens e.g. on GNU Bash v4.4 (e.g.
https://www.tutorialspoint.com/execute_bash_online.php ).
Best regards,
Jaan
- Quoting and string comparison,
Jaan Vajakas <=