diff options
author | Richard Jones <rjones@redhat.com> | 2010-04-13 22:06:43 +0100 |
---|---|---|
committer | Richard Jones <rjones@redhat.com> | 2010-04-13 22:09:21 +0100 |
commit | ad752b80d7fa064b7bdd3d4c8d47c95d79265b58 (patch) | |
tree | 22a8e3f35344fbe0659f824c5434c116c6797c74 /fish | |
parent | c076aaea7e6d9459c8d8a96d21abd71a0223f098 (diff) | |
download | libguestfs-ad752b80d7fa064b7bdd3d4c8d47c95d79265b58.tar.gz libguestfs-ad752b80d7fa064b7bdd3d4c8d47c95d79265b58.tar.xz libguestfs-ad752b80d7fa064b7bdd3d4c8d47c95d79265b58.zip |
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.
Diffstat (limited to 'fish')
-rw-r--r-- | fish/fish.c | 15 |
1 files changed, 13 insertions, 2 deletions
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); } } |