X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=fish%2Ffish.c;h=1309c680170ff305323f634e8a4ace385c46cc74;hb=e88c37bc71a54f1b8cff6a4bdc04b39fc32b28bf;hp=fcafb5caa0f24e9a18234f3345a996f192e6622f;hpb=4581eb2523eeb4d094d53af0555cb7e0f760ae2d;p=libguestfs.git diff --git a/fish/fish.c b/fish/fish.c index fcafb5c..1309c68 100644 --- a/fish/fish.c +++ b/fish/fish.c @@ -26,7 +26,9 @@ #include #include #include +#include #include +#include #ifdef HAVE_LIBREADLINE #include @@ -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 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");