From ad752b80d7fa064b7bdd3d4c8d47c95d79265b58 Mon Sep 17 00:00:00 2001 From: Richard Jones Date: Tue, 13 Apr 2010 22:06:43 +0100 Subject: fish: Allow '-' prefix on command line to override exit on error (RHBZ#578407). Allow -cmd on the command line to mean that normal exit on error behaviour is overridden, ie. we will not exit. This allows you to do: guestfish -- command : -command : command with the second command allowing errors. (Note that '--' is required to stop getopt parsing -command as an option). Also this fixes the remote case which is what the original bug report was about. --- fish/fish.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'fish') diff --git a/fish/fish.c b/fish/fish.c index bd13a827..61a84050 100644 --- a/fish/fish.c +++ b/fish/fish.c @@ -768,6 +768,15 @@ cmdline (char *argv[], int optind, int argc) fprintf (stderr, _("%s: empty command on command line\n"), program_name); exit (EXIT_FAILURE); } + + /* Allow -cmd on the command line to mean (temporarily) override + * the normal exit on error (RHBZ#578407). + */ + if (cmd[0] == '-') { + exit_on_error = 0; + cmd++; + } + params = &argv[optind]; /* Search for end of command list or ":" ... */ @@ -775,10 +784,12 @@ cmdline (char *argv[], int optind, int argc) optind++; if (optind == argc) { - if (issue_command (cmd, params, NULL) == -1) exit (EXIT_FAILURE); + if (issue_command (cmd, params, NULL) == -1 && exit_on_error) + exit (EXIT_FAILURE); } else { argv[optind] = NULL; - if (issue_command (cmd, params, NULL) == -1) exit (EXIT_FAILURE); + if (issue_command (cmd, params, NULL) == -1 && exit_on_error) + exit (EXIT_FAILURE); cmdline (argv, optind+1, argc); } } -- cgit