.IP 3) 4
An empty folder is not in itself an error.
.PP
-Message numbers greater than the highest existing message in a folder
-as part of a range designation are replaced with the next free message
-number.
+A message number less than that of the smallest existing message in a
+folder is treated as if the message already exists. A message number
+greater than that of the highest existing message in a folder causes
+an \*(lqout of range\*(rq error message to be displayed.
+.PP
+As part of a range designation that contains messages that do exist,
+message numbers less than the smallest, or greater than the highest,
+existing message in a folder are ignored.
.PP
Examples: The current folder foo contains messages 3 5 6.
Cur is 4.
/r/phyl/Mail/foo/6
% mhpath 2001
-/r/phyl/Mail/foo/7
+mhpath: message 2001 out of range 1-6
% mhpath 1\-2001
/r/phyl/Mail/foo/3
/r/phyl/Mail/foo/7
% mhpath last\-new
-bad message list \*(lqlast\-new\*(rq.
+mhpath: bad message list last\-new
% mhpath cur
/r/phyl/Mail/foo/4
% mhpath 1\-2
-no messages in range \*(lq1\-2\*(rq.
+mhpath: no messages in range 1\-2
% mhpath first:2
/r/phyl/Mail/foo/3
--- /dev/null
+#!/bin/sh
+######################################################
+#
+# Test mhpath
+#
+######################################################
+
+set -e
+
+if test -z "${MH_OBJ_DIR}"; then
+ srcdir=`dirname $0`/../..
+ MH_OBJ_DIR=`cd $srcdir && pwd`; export MH_OBJ_DIR
+fi
+
+. "$MH_OBJ_DIR/test/common.sh"
+
+setup_test
+
+expected=$MH_TEST_DIR/$$.expected
+actual=$MH_TEST_DIR/$$.actual
+
+
+# check -help
+cat > $expected <<EOF
+Usage: mhpath [+folder] [msgs] [switches]
+ switches are:
+ -version
+ -help
+EOF
+# The exit status is 1 with -help, so invert it to prevent
+# triggering immediate exit due to set -e.
+! mhpath -help > $actual 2>&1
+check $expected $actual
+
+# check -version
+if ! mhpath -v | grep '^mhpath --' > /dev/null; then
+ echo "$0: mhpath -v generated unexpected output" 1>&2
+ failed=`expr ${failed:-0} + 1`
+fi
+
+# check +
+check_string "mhpath +" "$MH_TEST_DIR/Mail"
+
+# check with no options
+folder -fast +inbox > /dev/null
+check_string "mhpath" "$MH_TEST_DIR/Mail/inbox"
+
+# check +inbox
+check_string "mhpath +inbox" "$MH_TEST_DIR/Mail/inbox"
+
+# check all
+cat > $expected <<EOF
+$MH_TEST_DIR/Mail/inbox/1
+$MH_TEST_DIR/Mail/inbox/2
+$MH_TEST_DIR/Mail/inbox/3
+$MH_TEST_DIR/Mail/inbox/4
+$MH_TEST_DIR/Mail/inbox/5
+$MH_TEST_DIR/Mail/inbox/6
+$MH_TEST_DIR/Mail/inbox/7
+$MH_TEST_DIR/Mail/inbox/8
+$MH_TEST_DIR/Mail/inbox/9
+$MH_TEST_DIR/Mail/inbox/10
+EOF
+mhpath all > $actual 2>&1
+check $expected $actual
+
+# check message number greater than highest
+check_string "mhpath 11" "mhpath: message 11 out of range 1-10"
+check_string "mhpath 10 11" "mhpath: message 11 out of range 1-10"
+
+# check range with message number greater than highest
+cat > $expected <<EOF
+$MH_TEST_DIR/Mail/inbox/1
+$MH_TEST_DIR/Mail/inbox/2
+$MH_TEST_DIR/Mail/inbox/3
+$MH_TEST_DIR/Mail/inbox/4
+$MH_TEST_DIR/Mail/inbox/5
+$MH_TEST_DIR/Mail/inbox/6
+$MH_TEST_DIR/Mail/inbox/7
+$MH_TEST_DIR/Mail/inbox/8
+$MH_TEST_DIR/Mail/inbox/9
+$MH_TEST_DIR/Mail/inbox/10
+EOF
+mhpath 1-99999 > $actual 2>&1
+check $expected $actual
+
+# check new
+check_string "mhpath new" "$MH_TEST_DIR/Mail/inbox/11"
+
+# check multiple msgs, including new
+cat > $expected <<EOF
+$MH_TEST_DIR/Mail/inbox/1
+$MH_TEST_DIR/Mail/inbox/10
+$MH_TEST_DIR/Mail/inbox/11
+EOF
+mhpath first last new > $actual 2>&1
+check $expected $actual
+
+# check invalid message list using names
+check_string "mhpath last-new" "mhpath: bad message list last-new"
+
+# check cur
+folder +inbox 5 > /dev/null
+check_string "mhpath cur" "$MH_TEST_DIR/Mail/inbox/5"
+
+# check prev
+check_string "mhpath prev" "$MH_TEST_DIR/Mail/inbox/4"
+
+# check next
+check_string "mhpath next" "$MH_TEST_DIR/Mail/inbox/6"
+
+# check invalid message list using numbers
+rmm 1-2
+check_string "mhpath 1-2" "mhpath: no messages in range 1-2"
+
+# check ignoring of out-of-range message numbers in ranges
+check_string "mhpath 1-3" "$MH_TEST_DIR/Mail/inbox/3"
+check_string "mhpath first-3" "$MH_TEST_DIR/Mail/inbox/3"
+check_string "mhpath 10-11" "$MH_TEST_DIR/Mail/inbox/10"
+check_string "mhpath last-11" "$MH_TEST_DIR/Mail/inbox/10"
+
+# check reference to existing messages
+cat > $expected <<EOF
+$MH_TEST_DIR/Mail/inbox/3
+$MH_TEST_DIR/Mail/inbox/4
+EOF
+mhpath first:2 > $actual 2>&1
+check $expected $actual
+
+# check reference to non-existant messages
+cat > $expected <<EOF
+$MH_TEST_DIR/Mail/inbox/1
+$MH_TEST_DIR/Mail/inbox/2
+EOF
+mhpath 1 2 > $actual 2>&1
+check $expected $actual
+
+
+exit $failed