1 #!/bin/bash 2 3 [ -f testing.sh ] && . testing.sh 4 5 testing "expr integer" "expr 5" "5\n" "" "" 6 testing "expr integer negative" "expr -5" "-5\n" "" "" 7 testing "expr string" "expr astring" "astring\n" "" "" 8 testing "expr 1 + 3" "expr 1 + 3" "4\n" "" "" 9 testing "expr 5 + 6 * 3" "expr 5 + 6 \* 3" "23\n" "" "" 10 testing "expr ( 5 + 6 ) * 3" "expr \( 5 + 6 \) \* 3" "33\n" "" "" 11 testing "expr * / same priority" "expr 4 \* 3 / 2" "6\n" "" "" 12 testing "expr / * same priority" "expr 3 / 2 \* 4" "4\n" "" "" 13 testing "expr & before |" "expr 0 \| 1 \& 0" "0\n" "" "" 14 testing "expr | after &" "expr 1 \| 0 \& 0" "1\n" "" "" 15 testing "expr | & same priority" "expr 0 \& 0 \| 1" "1\n" "" "" 16 testing "expr % * same priority" "expr 3 % 2 \* 4" "4\n" "" "" 17 testing "expr * % same priority" "expr 3 \* 2 % 4" "2\n" "" "" 18 testing "expr = > same priority" "expr 0 = 2 \> 3" "0\n" "" "" 19 testing "expr > = same priority" "expr 3 \> 2 = 1" "1\n" "" "" 20 testing "expr string becomes integer" "expr ab21xx : '[^0-9]*\([0-9]*\)' + 3" \ 21 "24\n" "" "" 22