Browse Source

[cmdline] Allow ";" as an unconditional command separator

It is currently possible to construct a sequence of commands to be
executed regardless of success or failure using "|| &&" as the command
separator.  (The "||" captures the failure case, the blank command
converts it to a success case.)

Allow ";" to be used as a more visually appealing (and
space-efficient) alternative.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 13 years ago
parent
commit
1f4c5f90c3
1 changed files with 14 additions and 0 deletions
  1. 14
    0
      src/core/exec.c

+ 14
- 0
src/core/exec.c View File

142
 	return ( rc != 0 );
142
 	return ( rc != 0 );
143
 }
143
 }
144
 
144
 
145
+/**
146
+ * Process next command regardless of status from previous command
147
+ *
148
+ * @v rc		Status of previous command
149
+ * @ret process		Process next command
150
+ */
151
+static int process_always ( int rc __unused ) {
152
+	return 1;
153
+}
154
+
145
 /**
155
 /**
146
  * Find command terminator
156
  * Find command terminator
147
  *
157
  *
166
 			/* Short-circuit logical AND */
176
 			/* Short-circuit logical AND */
167
 			*process_next = process_on_success;
177
 			*process_next = process_on_success;
168
 			return i;
178
 			return i;
179
+		} else if ( strcmp ( tokens[i], ";" ) == 0 ) {
180
+			/* Process next command unconditionally */
181
+			*process_next = process_always;
182
+			return i;
169
 		}
183
 		}
170
 	}
184
 	}
171
 
185
 

Loading…
Cancel
Save