summaryrefslogtreecommitdiffstats
path: root/fish
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2011-01-18 10:33:01 +0000
committerRichard W.M. Jones <rjones@redhat.com>2011-01-18 10:33:01 +0000
commit4bcb267a248977c6b044e18a72266d665102de30 (patch)
treef0d3db1749d4495a696dfdc278a3da560b54f981 /fish
parentf6a21c1e0d44f9db409ce6583be7b5bc694767a8 (diff)
downloadlibguestfs-4bcb267a248977c6b044e18a72266d665102de30.tar.gz
libguestfs-4bcb267a248977c6b044e18a72266d665102de30.tar.xz
libguestfs-4bcb267a248977c6b044e18a72266d665102de30.zip
fish: Make exit_on_error into a completely local variable.
Note that 'time' and 'glob' (which both run subcommands) do not correctly pass the exit_on_error flag in the remote case. This is not a regression: the current code doesn't work either.
Diffstat (limited to 'fish')
-rw-r--r--fish/fish.c18
-rw-r--r--fish/fish.h2
-rw-r--r--fish/glob.c2
-rw-r--r--fish/rc.c2
-rw-r--r--fish/time.c2
5 files changed, 16 insertions, 10 deletions
diff --git a/fish/fish.c b/fish/fish.c
index 711073a2..fbc364fc 100644
--- a/fish/fish.c
+++ b/fish/fish.c
@@ -69,7 +69,6 @@ int verbose = 0;
int remote_control_listen = 0;
int remote_control_csh = 0;
int remote_control = 0;
-static int exit_on_error = 1;
int command_num = 0;
int keys_from_stdin = 0;
int echo_keys = 0;
@@ -611,6 +610,7 @@ script (int prompt)
char *argv[64];
int len;
int global_exit_on_error = !prompt;
+ int exit_on_error;
int tilde_candidate;
if (prompt) {
@@ -798,7 +798,7 @@ script (int prompt)
argv[i] = NULL;
got_command:
- if (issue_command (cmd, argv, pipe) == -1) {
+ if (issue_command (cmd, argv, pipe, exit_on_error) == -1) {
if (exit_on_error) exit (EXIT_FAILURE);
}
@@ -812,6 +812,7 @@ cmdline (char *argv[], int optind, int argc)
{
const char *cmd;
char **params;
+ int exit_on_error;
exit_on_error = 1;
@@ -838,18 +839,23 @@ cmdline (char *argv[], int optind, int argc)
optind++;
if (optind == argc) {
- if (issue_command (cmd, params, NULL) == -1 && exit_on_error)
+ if (issue_command (cmd, params, NULL, exit_on_error) == -1 && exit_on_error)
exit (EXIT_FAILURE);
} else {
argv[optind] = NULL;
- if (issue_command (cmd, params, NULL) == -1 && exit_on_error)
+ if (issue_command (cmd, params, NULL, exit_on_error) == -1 && exit_on_error)
exit (EXIT_FAILURE);
cmdline (argv, optind+1, argc);
}
}
+/* Note: 'rc_exit_on_error_flag' is the exit_on_error flag that we
+ * pass to the remote server (when issuing --remote commands). It
+ * does not cause issue_command itself to exit on error.
+ */
int
-issue_command (const char *cmd, char *argv[], const char *pipecmd)
+issue_command (const char *cmd, char *argv[], const char *pipecmd,
+ int rc_exit_on_error_flag)
{
int argc;
int stdout_saved_fd = -1;
@@ -912,7 +918,7 @@ issue_command (const char *cmd, char *argv[], const char *pipecmd)
/* If --remote was set, then send this command to a remote process. */
if (remote_control)
- r = rc_remote (remote_control, cmd, argc, argv, exit_on_error);
+ r = rc_remote (remote_control, cmd, argc, argv, rc_exit_on_error_flag);
/* Otherwise execute it locally. */
else if (STRCASEEQ (cmd, "help")) {
diff --git a/fish/fish.h b/fish/fish.h
index f4b6c9cb..da0c6a73 100644
--- a/fish/fish.h
+++ b/fish/fish.h
@@ -63,7 +63,7 @@ extern int have_terminfo;
extern int progress_bars;
extern int remote_control_csh;
extern const char *libvirt_uri;
-extern int issue_command (const char *cmd, char *argv[], const char *pipe);
+extern int issue_command (const char *cmd, char *argv[], const char *pipe, int rc_exit_on_error_flag);
extern void list_builtin_commands (void);
extern int display_builtin_command (const char *cmd);
extern void free_strings (char **argv);
diff --git a/fish/glob.c b/fish/glob.c
index 509532b8..8250c138 100644
--- a/fish/glob.c
+++ b/fish/glob.c
@@ -144,7 +144,7 @@ glob_issue (char *cmd, size_t argc,
for (i = 1; i < argc; ++i)
argv[i] = globs[i][posn[i]];
- if (issue_command (argv[0], &argv[1], NULL) == -1)
+ if (issue_command (argv[0], &argv[1], NULL, 0) == -1)
*r = -1; /* ... but don't exit */
for (i = argc-1; i >= 1; --i) {
diff --git a/fish/rc.c b/fish/rc.c
index a2bde4ae..721c6133 100644
--- a/fish/rc.c
+++ b/fish/rc.c
@@ -284,7 +284,7 @@ rc_listen (void)
}
/* Run the command. */
- reply.r = issue_command (call.cmd, argv, NULL);
+ reply.r = issue_command (call.cmd, argv, NULL, 0);
xdr_free ((xdrproc_t) xdr_guestfish_call, (char *) &call);
diff --git a/fish/time.c b/fish/time.c
index 931403f2..3a460492 100644
--- a/fish/time.c
+++ b/fish/time.c
@@ -39,7 +39,7 @@ run_time (const char *cmd, size_t argc, char *argv[])
gettimeofday (&start_t, NULL);
- if (issue_command (argv[0], &argv[1], NULL) == -1)
+ if (issue_command (argv[0], &argv[1], NULL, 0) == -1)
return -1;
gettimeofday (&end_t, NULL);