Index: /trunk/ippScripts/scripts/detrend_reject_exp.pl
===================================================================
--- /trunk/ippScripts/scripts/detrend_reject_exp.pl	(revision 9820)
+++ /trunk/ippScripts/scripts/detrend_reject_exp.pl	(revision 9821)
@@ -188,5 +188,5 @@
     my $command = "$dettool -updatedetrun -det_id $det_id";
     if ($stop) {
-	$command .= ' -stop';
+	$command .= ' -state stop';
     } else {
 	$command .= ' -again';
Index: /trunk/ippTools/scripts/dettest.sh
===================================================================
--- /trunk/ippTools/scripts/dettest.sh	(revision 9820)
+++ /trunk/ippTools/scripts/dettest.sh	(revision 9821)
@@ -61,3 +61,3 @@
 dettool -residexp || exit 1
 
-dettool -updatedetrun -det_id $det_id -stop || exit 1
+dettool -updatedetrun -det_id $det_id -state stop || exit 1
Index: /trunk/ippTools/src/dettool.c
===================================================================
--- /trunk/ippTools/src/dettool.c	(revision 9820)
+++ /trunk/ippTools/src/dettool.c	(revision 9821)
@@ -4285,5 +4285,5 @@
         return false;
     }
-    // either -rerun or -stop must be specified
+    // either -rerun or -state must be specified
     bool again = psMetadataLookupBool(&status, config->args, "-again");
     if (!status) {
@@ -4291,21 +4291,21 @@
         return false;
     }
-    bool stop = psMetadataLookupBool(&status, config->args, "-stop");
-    if (!status) {
-        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -stop");
-        return false;
-    }
-    if (!(again || stop)) {
-        psError(PS_ERR_UNKNOWN, true, "either -again or -stop must be specified");
-        return false;
-    }
-    if (again && stop) {
-        psError(PS_ERR_UNKNOWN, true, "either -again or -stop must be specified");
-        return false;
-    }
-
-    if (stop) {
-        // set detRun.state to stop
-        return setDetRunState(config, det_id, "stop");
+    psString state = psMetadataLookupStr(&status, config->args, "-state");
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -state");
+        return false;
+    }
+    if (!(again || state)) {
+        psError(PS_ERR_UNKNOWN, true, "either -again or -state must be specified");
+        return false;
+    }
+    if (again && state) {
+        psError(PS_ERR_UNKNOWN, true, "either -again or -state must be specified");
+        return false;
+    }
+
+    if (state) {
+        // set detRun.state to state
+        return setDetRunState(config, det_id, state);
     }
 
@@ -4926,4 +4926,16 @@
     PS_ASSERT_PTR_NON_NULL(state, false);
 
+    // check that state is a valid string value
+    if (!(
+            (strncmp(state, "run", 4) == 0) 
+            || (strncmp(state, "stop", 5) == 0) 
+            || (strncmp(state, "reg", 4) == 0) 
+        )
+    ) {
+        psError(PS_ERR_UNKNOWN, false,
+                "invalid detRun state: %s", state);
+        return false;
+    }
+
     char *query = "UPDATE detRun SET state = '%s' WHERE det_id = '%s'";
     if (!p_psDBRunQuery(config->dbh, query, state, det_id)) {
Index: /trunk/ippTools/src/dettoolConfig.c
===================================================================
--- /trunk/ippTools/src/dettoolConfig.c	(revision 9820)
+++ /trunk/ippTools/src/dettoolConfig.c	(revision 9821)
@@ -509,6 +509,6 @@
     psMetadataAddBool(updatedetrunArgs, PS_LIST_TAIL, "-again",  0,
         "start a new iteration of this detrend run", false);
-    psMetadataAddBool(updatedetrunArgs, PS_LIST_TAIL, "-stop",  0,
-        "stop this detrend run", false);
+    psMetadataAddStr(updatedetrunArgs, PS_LIST_TAIL, "-state",  0,
+        "set the state of this detrend run", false);
 
     // -rerun
