Imported from ../bash-2.02.tar.gz.
[platform/upstream/bash.git] / flags.c
diff --git a/flags.c b/flags.c
index 02b466c..34924b9 100644 (file)
--- a/flags.c
+++ b/flags.c
@@ -209,8 +209,8 @@ find_flag (name)
 }
 
 /* Change the state of a flag, and return it's original value, or return
-   FLAG_ERROR if there is no flag called NAME.  ON_OR_OFF should be one
-   of FLAG_ON or FLAG_OFF. */
+   FLAG_ERROR if there is no flag FLAG.  ON_OR_OFF must be either
+   FLAG_ON or FLAG_OFF. */
 int
 change_flag (flag, on_or_off)
   int flag;
@@ -226,17 +226,12 @@ change_flag (flag, on_or_off)
     return (FLAG_ERROR);
 #endif /* RESTRICTED_SHELL */
 
-  if (value == (int *)FLAG_UNKNOWN)
+  if ((value == (int *)FLAG_UNKNOWN) || (on_or_off != FLAG_ON && on_or_off != FLAG_OFF))
     return (FLAG_ERROR);
 
   old_value = *value;
 
-  if (on_or_off == FLAG_ON)
-    *value = 1;
-  else if (on_or_off == FLAG_OFF)
-    *value = 0;
-  else
-    return (FLAG_ERROR);
+  *value = (on_or_off == FLAG_ON) ? 1 : 0;
 
   /* Special cases for a few flags. */
   switch (flag)