cd $MH_TEST_DIR
# check -help
-cat >$expected <<EOF
+cat >"$expected" <<EOF
Usage: sortm [+folder] [msgs] [switches]
switches are:
-datefield field
-limit days
-nolimit
-[no]verbose
+ -[no]all
-version
-help
EOF
-sortm -help >$actual 2>&1
-check $expected $actual
+sortm -help >"$actual" 2>&1
+check "$expected" "$actual"
# check -version
case `sortm -version` in
failed=`expr ${failed:-0} + 1`;;
esac
-cat > $MH_TEST_DIR/Mail/inbox/11 <<EOF || exit 1
+cat >$MH_TEST_DIR/Mail/inbox/11 <<EOF || exit 1
From: Test11 <test11@example.com>
To: Some User <user@example.com>
Date: Fri, 29 Sep 2006 00:00:01
This is message number 11
EOF
-cat > $MH_TEST_DIR/Mail/inbox/12 <<EOF || exit 1
+cat >$MH_TEST_DIR/Mail/inbox/12 <<EOF || exit 1
From: Test12 <test12@example.com>
To: Some User <user@example.com>
Date: Thu, 28 Sep 2006 23:59:59
EOF
# check with no options
-cat >$expected <<EOF
+cat >"$expected" <<EOF
1 09/28 Test12 common subject<<This is message number 12 >>
2 09/29 Test1 Testing message 1<<This is message number 1 >>
3 09/29 Test2 Testing message 2<<This is message number 2 >>
EOF
sortm
-scan > $actual
-check $expected $actual
+scan >"$actual"
+check "$expected" "$actual"
# check +folder
-cat >$expected <<EOF
+cat >"$expected" <<EOF
1 09/28 Test12 common subject<<This is message number 12 >>
2+ 09/29 Test1 Testing message 1<<This is message number 1 >>
3 09/29 Test2 Testing message 2<<This is message number 2 >>
12 09/29 Test11 Re: common subject<<This is message number 11 >>
EOF
-refile first +inbox
-folder -pack > /dev/null
+refile first +inbox; folder -pack >/dev/null
sortm +inbox
-scan > $actual
-check $expected $actual
+scan >"$actual"
+check "$expected" "$actual"
# check -verbose
-cat >$expected <<EOF
+cat >"$expected" <<EOF
sorting by datefield date
renaming message chain from 12 to 1
message 11 becomes message 12
12 09/29 Test11 Re: common subject<<This is message number 11 >>
EOF
-refile first +inbox
-folder -pack > /dev/null
-sortm -verbose >$actual
-scan >> $actual
-check $expected $actual
+refile first +inbox; folder -pack >/dev/null
+sortm -verbose >"$actual"
+scan >>"$actual"
+check "$expected" "$actual"
# check -noverbose
-cat >$expected <<EOF
+cat >"$expected" <<EOF
1 09/28 Test12 common subject<<This is message number 12 >>
2+ 09/29 Test1 Testing message 1<<This is message number 1 >>
3 09/29 Test2 Testing message 2<<This is message number 2 >>
12 09/29 Test11 Re: common subject<<This is message number 11 >>
EOF
-refile first +inbox
-folder -pack > /dev/null
-sortm -verbose -noverbose >$actual
-scan >> $actual
-check $expected $actual
+refile first +inbox; folder -pack >/dev/null
+sortm -verbose -noverbose >"$actual"
+scan >>"$actual"
+check "$expected" "$actual"
# check msgs
-cat >$expected <<EOF
+cat >"$expected" <<EOF
1 09/28 Test12 common subject<<This is message number 12 >>
2 09/29 Test2 Testing message 2<<This is message number 2 >>
3 09/29 Test3 Testing message 3<<This is message number 3 >>
12+ 09/29 Test1 Testing message 1<<This is message number 1 >>
EOF
-refile first +inbox
-folder -pack > /dev/null
+refile first +inbox; folder -pack >/dev/null
sortm first last
-scan > $actual
-check $expected $actual
+scan >"$actual"
+check "$expected" "$actual"
# check -datefield
-cat >$expected <<EOF
+cat >"$expected" <<EOF
1 09/29 Test11 Re: common subject<<This is message number 11 >>
2 09/29 Test2 Testing message 2<<This is message number 2 >>
3 09/29 Test3 Testing message 3<<This is message number 3 >>
EOF
sortm -datefield Alt-Date 1 11
-scan > $actual
-check $expected $actual
+scan >"$actual"
+check "$expected" "$actual"
# check -textfield subject (datefield major, subjects grouped)
-cat >$expected <<EOF
+cat >"$expected" <<EOF
1 09/28 Test12 common subject<<This is message number 12 >>
2 09/29 Test11 Re: common subject<<This is message number 11 >>
3 09/29 Test2 Testing message 2<<This is message number 2 >>
EOF
sortm -textfield subject
-scan > $actual
-check $expected $actual
+scan >"$actual"
+check "$expected" "$actual"
# check -nolimit
-cat >$expected <<EOF
+cat >"$expected" <<EOF
1 09/28 Test12 common subject<<This is message number 12 >>
2 09/29 Test11 Re: common subject<<This is message number 11 >>
3 09/29 Test2 Testing message 2<<This is message number 2 >>
EOF
sortm -textfield subject -limit 0 -nolimit
-scan > $actual
-check $expected $actual
+scan >"$actual"
+check "$expected" "$actual"
# check -textfield subject -limit 0 (subject sort)
-cat >$expected <<EOF
+cat >"$expected" <<EOF
1 09/29 Test11 Re: common subject<<This is message number 11 >>
2 09/28 Test12 common subject<<This is message number 12 >>
3 09/29 Test1 Testing message 1<<This is message number 1 >>
12+ 09/29 Test9 Testing message 9<<This is message number 9 >>
EOF
-refile 2-7 +inbox; refile 1 +inbox; folder -pa last >/dev/null
+refile 2-7 +inbox; refile 1 +inbox; folder -pack last >/dev/null
sortm -textfield subject -limit 0
-scan > $actual
-check $expected $actual
+scan >"$actual"
+check "$expected" "$actual"
# check -textfield -limit 0 (text sort)
-cat >$expected <<EOF
+cat >"$expected" <<EOF
1 09/29 Test10 Testing message 10<<This is message number 10 >>
2 09/29 Test11 Re: common subject<<This is message number 11 >>
3 09/28 Test12 common subject<<This is message number 12 >>
12+ 09/29 Test9 Testing message 9<<This is message number 9 >>
EOF
-refile 2-7 +inbox; refile 1 +inbox; folder -pa last >/dev/null
+refile 2-7 +inbox; refile 1 +inbox; folder -pack last >/dev/null
sortm -textfield from -limit 0
-scan > $actual
-check $expected $actual
+scan >"$actual"
+check "$expected" "$actual"
# check -textfield with finite -limit that doesn't cover message 13
-cat > $MH_TEST_DIR/Mail/inbox/13 <<EOF || exit 1
+cat >$MH_TEST_DIR/Mail/inbox/13 <<EOF || exit 1
From: Test13 <test13@example.com>
To: Some User <user@example.com>
Date: Tue, 31 Oct 2006 23:59:59
This is message number 13
EOF
-cat >$expected <<EOF
+cat >"$expected" <<EOF
1 09/28 Test12 common subject<<This is message number 12 >>
2 09/29 Test11 Re: common subject<<This is message number 11 >>
3 09/29 Test5 Testing message 5<<This is message number 5 >>
13 10/31 Test13 Re: common subject<<This is message number 13 >>
EOF
-refile 2-7 +inbox; refile 1 +inbox; folder -pa last >/dev/null
+refile 2-7 +inbox; refile 1 +inbox; folder -pack last >/dev/null
sortm -textfield subject -limit 10
-scan > $actual
-check $expected $actual
+scan >"$actual"
+check "$expected" "$actual"
# check -textfield with finite -limit that does cover message 13
-cat >$expected <<EOF
+cat >"$expected" <<EOF
1 09/28 Test12 common subject<<This is message number 12 >>
2 09/29 Test11 Re: common subject<<This is message number 11 >>
3 10/31 Test13 Re: common subject<<This is message number 13 >>
13+ 09/29 Test9 Testing message 9<<This is message number 9 >>
EOF
-refile 2-7 +inbox; refile 1 +inbox; folder -pa last >/dev/null
+refile 2-7 +inbox; refile 1 +inbox; folder -pack last >/dev/null
sortm -textfield subject -limit 60
-scan > $actual
-check $expected $actual
+scan >"$actual"
+check "$expected" "$actual"
# check -notextfield
-cat >$expected <<EOF
+cat >"$expected" <<EOF
1 09/28 Test12 common subject<<This is message number 12 >>
2 09/29 Test10 Testing message 10<<This is message number 10 >>
3 09/29 Test5 Testing message 5<<This is message number 5 >>
13+ 10/31 Test13 Re: common subject<<This is message number 13 >>
EOF
-refile 2-7 +inbox; refile 1 +inbox; folder -pa last >/dev/null
+refile 2-7 +inbox; refile 1 +inbox; folder -pack last >/dev/null
sortm -textfield subject -limit 60 -notextfield
-scan > $actual
-check $expected $actual
+scan >"$actual"
+check "$expected" "$actual"
-exit $failed
+# check -noall
+run_test 'sortm -noall' 'sortm: must specify messages to sort with -noall'
+
+# check -all
+cat >"$expected" <<EOF
+ 1 09/28 Test12 common subject<<This is message number 12 >>
+ 2+ 09/29 Test10 Testing message 10<<This is message number 10 >>
+ 3 09/29 Test5 Testing message 5<<This is message number 5 >>
+ 4 09/29 Test6 Testing message 6<<This is message number 6 >>
+ 5 09/29 Test7 Testing message 7<<This is message number 7 >>
+ 6 09/29 Test8 Testing message 8<<This is message number 8 >>
+ 7 09/29 Test9 Testing message 9<<This is message number 9 >>
+ 8 09/29 Test1 Testing message 1<<This is message number 1 >>
+ 9 09/29 Test2 Testing message 2<<This is message number 2 >>
+ 10 09/29 Test3 Testing message 3<<This is message number 3 >>
+ 11 09/29 Test4 Testing message 4<<This is message number 4 >>
+ 12 09/29 Test11 Re: common subject<<This is message number 11 >>
+ 13 10/31 Test13 Re: common subject<<This is message number 13 >>
+EOF
+
+refile first +inbox; folder -pack >/dev/null
+sortm -noall -all
+scan >"$actual"
+check "$expected" "$actual"
+
+
+exit ${failed:-0}