/* Perform the state transition if the command completed
successfully (at least in part). */
- if (result != 0)
+ if (result != CMD_FAILURE)
{
pgm_state = cp->transition[pgm_state];
return lex_end_of_command ();
}
+
+#define assert_not_safer() \
+ do { \
+ if (set_safer) \
+ { \
+ msg (SE, _("This command not allowed when the SAFER option is set.")); \
+ return CMD_FAILURE; \
+ } \
+} while(0)
+
+
+
/* Parses, performs the ERASE command. */
int
cmd_erase (void)
{
- if (set_safer)
- {
- msg (SE, _("This command not allowed when the SAFER option is set."));
- return CMD_FAILURE;
- }
+
+ assert_not_safer();
lex_match_id ("ERASE");
if (!lex_force_match_id ("FILE"))
return CMD_FAILURE;
}
- return lex_end_of_command ();
+ return CMD_SUCCESS;
}
-#if unix
+#ifdef unix
/* Spawn a shell process. */
static int
shell (void)
{
int code;
- if (set_safer)
- {
- msg (SE, _("This command not allowed when the SAFER option is set."));
- return CMD_FAILURE;
- }
+ assert_not_safer();
lex_match_id ("HOST");
-#if unix
+#ifdef unix
/* Figure out whether to invoke an interactive shell or to execute a
single shell command. */
if (lex_look_ahead () == '.')