| 1 | #!/bin/bashscip-shell filesystem . . `/bin/bash`. |
| 2 | # test-suite.sh |
| 3 | # A partial Bash compatibility test suite. |
| 4 | # Run this on your version of Bash, or some other shell. |
| 5 | |
| 6 | default_option=FAIL # Tests below will fail unless . . . |
| 7 | |
| 8 | echoscip-shell system . . echo. |
| 9 | echoscip-shell system . . echo. -n "Testing " |
| 10 | sleepscip-shell system . . sleep. 1; echoscip-shell system . . echo. -n ". " |
| 11 | sleepscip-shell system . . sleep. 1; echoscip-shell system . . echo. -n ". " |
| 12 | sleepscip-shell system . . sleep. 1; echoscip-shell system . . echo. ". " |
| 13 | echoscip-shell system . . echo. |
| 14 | |
| 15 | # Double brackets |
| 16 | String="Double brackets supported?" |
| 17 | echoscip-shell system . . echo. -n "Double brackets test: " |
| 18 | if [[ "$String" = "Double brackets supported?" ]] |
| 19 | then |
| 20 | echoscip-shell system . . echo. "PASS" |
| 21 | else |
| 22 | echoscip-shell system . . echo. "FAIL" |
| 23 | fi |
| 24 | |
| 25 | |
| 26 | # Double brackets and regex matching |
| 27 | String="Regex matching supported?" |
| 28 | echoscip-shell system . . echo. -n "Regex matching: " |
| 29 | if [[ "$String" =~ R.....matching* ]] |
| 30 | then |
| 31 | echoscip-shell system . . echo. "PASS" |
| 32 | else |
| 33 | echoscip-shell system . . echo. "FAIL" |
| 34 | fi |
| 35 | |
| 36 | |
| 37 | # Arrays |
| 38 | test_arr=$default_option # FAIL |
| 39 | Array=( If supports arrays will print PASS ) |
| 40 | test_arr=${Array[5]} |
| 41 | echoscip-shell system . . echo. "Array test: $test_arr" |
| 42 | |
| 43 | |
| 44 | # Command Substitution |
| 45 | csub_testscip-shell shell abs-guide 10-4 csub_test(). () |
| 46 | { |
| 47 | echoscip-shell system . . echo. "PASS" |
| 48 | } |
| 49 | |
| 50 | test_csub=$default_option # FAIL |
| 51 | test_csub=$(csub_testscip-shell shell abs-guide 10-4 csub_test().) |
| 52 | echoscip-shell system . . echo. "Command substitution test: $test_csub" |
| 53 | |
| 54 | echoscip-shell system . . echo. |
| 55 | |
| 56 | # Completing this script is an exercise for the reader. |
| 57 | # Add to the above similar tests for double parentheses, |
| 58 | #+ brace expansion, process substitution, etc. |
| 59 | |
| 60 | exit $? |