X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=fish%2Ffish.c;h=a956bf9e427979064a2b3d6363cef86b07d3e687;hp=fcafb5caa0f24e9a18234f3345a996f192e6622f;hb=a4d88af2c13692e38fb7cfce77b082cee6e0462f;hpb=4ecdf8ec07d7eb4bfa4e1b5eef413e721a1f3711 diff --git a/fish/fish.c b/fish/fish.c index fcafb5c..a956bf9 100644 --- a/fish/fish.c +++ b/fish/fish.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #ifdef HAVE_LIBREADLINE @@ -359,6 +360,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");