| 1 | #!/bin/bashscip-shell filesystem . . `/bin/bash`. |
| 2 | # and list |
| 3 | |
| 4 | if [scip-shell system . . `[`. ! -z "$1" ] && echoscip-shell system . . echo. "Argument #1 = $1" && [scip-shell system . . `[`. ! -z "$2" ] && \ |
| 5 | # ^^ ^^ ^^ |
| 6 | echoscip-shell system . . echo. "Argument #2 = $2" |
| 7 | then |
| 8 | echoscip-shell system . . echo. "At least 2 arguments passed to script." |
| 9 | # All the chained commands return true. |
| 10 | else |
| 11 | echoscip-shell system . . echo. "Fewer than 2 arguments passed to script." |
| 12 | # At least one of the chained commands returns false. |
| 13 | fi |
| 14 | # Note that "if [ ! -z $1 ]" works, but its alleged equivalent, |
| 15 | # "if [ -n $1 ]" does not. |
| 16 | # However, quoting fixes this. |
| 17 | # if "[ -n "$1" ]" works. |
| 18 | # ^ ^ Careful! |
| 19 | # It is always best to QUOTE the variables being tested. |
| 20 | |
| 21 | |
| 22 | # This accomplishes the same thing, using "pure" if/then statements. |
| 23 | if [scip-shell system . . `[`. ! -z "$1" ] |
| 24 | then |
| 25 | echoscip-shell system . . echo. "Argument #1 = $1" |
| 26 | fi |
| 27 | if [scip-shell system . . `[`. ! -z "$2" ] |
| 28 | then |
| 29 | echoscip-shell system . . echo. "Argument #2 = $2" |
| 30 | echoscip-shell system . . echo. "At least 2 arguments passed to script." |
| 31 | else |
| 32 | echoscip-shell system . . echo. "Fewer than 2 arguments passed to script." |
| 33 | fi |
| 34 | # It's longer and more ponderous than using an "and list". |
| 35 | |
| 36 | |
| 37 | exit $? |