| 1 | #!/bin/bashscip-shell filesystem . . `/bin/bash`. |
| 2 | |
| 3 | a=4 |
| 4 | b=5 |
| 5 | |
| 6 | # Here "a" and "b" can be treated either as integers or strings. |
| 7 | # There is some blurring between the arithmetic and string comparisons, |
| 8 | #+ since Bash variables are not strongly typed. |
| 9 | |
| 10 | # Bash permits integer operations and comparisons on variables |
| 11 | #+ whose value consists of all-integer characters. |
| 12 | # Caution advised, however. |
| 13 | |
| 14 | echoscip-shell system . . echo. |
| 15 | |
| 16 | if [scip-shell system . . `[`. "$a" -ne "$b" ] |
| 17 | then |
| 18 | echoscip-shell system . . echo. "$a is not equal to $b" |
| 19 | echoscip-shell system . . echo. "(arithmetic comparison)" |
| 20 | fi |
| 21 | |
| 22 | echoscip-shell system . . echo. |
| 23 | |
| 24 | if [scip-shell system . . `[`. "$a" != "$b" ] |
| 25 | then |
| 26 | echoscip-shell system . . echo. "$a is not equal to $b." |
| 27 | echoscip-shell system . . echo. "(string comparison)" |
| 28 | # "4" != "5" |
| 29 | # ASCII 52 != ASCII 53 |
| 30 | fi |
| 31 | |
| 32 | # In this particular instance, both "-ne" and "!=" work. |
| 33 | |
| 34 | echoscip-shell system . . echo. |
| 35 | |
| 36 | exit 0 |