git.annexia.org
/
libguestfs.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix leak in realloc failure (Jim Meyering).
[libguestfs.git]
/
fish
/
fish.c
diff --git
a/fish/fish.c
b/fish/fish.c
index
894e351
..
1309c68
100644
(file)
--- a/
fish/fish.c
+++ b/
fish/fish.c
@@
-26,7
+26,9
@@
#include <unistd.h>
#include <fcntl.h>
#include <getopt.h>
#include <unistd.h>
#include <fcntl.h>
#include <getopt.h>
+#include <signal.h>
#include <assert.h>
#include <assert.h>
+#include <ctype.h>
#ifdef HAVE_LIBREADLINE
#include <readline/readline.h>
#ifdef HAVE_LIBREADLINE
#include <readline/readline.h>
@@
-359,6
+361,21
@@
script (int prompt)
/* If the next character is '#' then this is a comment. */
if (*buf == '#') continue;
/* If the next character is '#' then this is a comment. */
if (*buf == '#') continue;
+ /* If the next character is '!' then pass the whole lot to system(3). */
+ if (*buf == '!') {
+ int r;
+
+ r = system (buf+1);
+ if (!prompt) {
+ if (r == -1 ||
+ (WIFSIGNALED (r) &&
+ (WTERMSIG (r) == SIGINT || WTERMSIG (r) == SIGQUIT)) ||
+ WEXITSTATUS (r) != 0)
+ exit (1);
+ }
+ continue;
+ }
+
/* Get the command (cannot be quoted). */
len = strcspn (buf, " \t");
/* Get the command (cannot be quoted). */
len = strcspn (buf, " \t");
@@
-523,6
+540,8
@@
issue_command (const char *cmd, char *argv[])
else if (strcasecmp (cmd, "alloc") == 0 ||
strcasecmp (cmd, "allocate") == 0)
return do_alloc (cmd, argc, argv);
else if (strcasecmp (cmd, "alloc") == 0 ||
strcasecmp (cmd, "allocate") == 0)
return do_alloc (cmd, argc, argv);
+ else if (strcasecmp (cmd, "echo") == 0)
+ return do_echo (cmd, argc, argv);
else if (strcasecmp (cmd, "edit") == 0 ||
strcasecmp (cmd, "vi") == 0 ||
strcasecmp (cmd, "emacs") == 0)
else if (strcasecmp (cmd, "edit") == 0 ||
strcasecmp (cmd, "vi") == 0 ||
strcasecmp (cmd, "emacs") == 0)
@@
-543,6
+562,8
@@
list_builtin_commands (void)
printf ("%-20s %s\n",
"alloc", "allocate an image");
printf ("%-20s %s\n",
printf ("%-20s %s\n",
"alloc", "allocate an image");
printf ("%-20s %s\n",
+ "echo", "display a line of text");
+ printf ("%-20s %s\n",
"edit", "edit a file in the image");
/* actions are printed after this (see list_commands) */
"edit", "edit a file in the image");
/* actions are printed after this (see list_commands) */
@@
-570,6
+591,11
@@
display_builtin_command (const char *cmd)
" <nn>M or <nn>MB number of megabytes\n"
" <nn>G or <nn>GB number of gigabytes\n"
" <nn>sects number of 512 byte sectors\n");
" <nn>M or <nn>MB number of megabytes\n"
" <nn>G or <nn>GB number of gigabytes\n"
" <nn>sects number of 512 byte sectors\n");
+ else if (strcasecmp (cmd, "echo") == 0)
+ printf ("echo - display a line of text\n"
+ " echo [<params> ...]\n"
+ "\n"
+ " This echos the parameters to the terminal.\n");
else if (strcasecmp (cmd, "edit") == 0 ||
strcasecmp (cmd, "vi") == 0 ||
strcasecmp (cmd, "emacs") == 0)
else if (strcasecmp (cmd, "edit") == 0 ||
strcasecmp (cmd, "vi") == 0 ||
strcasecmp (cmd, "emacs") == 0)