From a4d88af2c13692e38fb7cfce77b082cee6e0462f Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Fri, 1 May 2009 17:41:28 +0100 Subject: [PATCH] Implement !local in guestfish. --- fish/fish.c | 16 ++++++++++++++++ guestfish.pod | 13 +++++++++++++ 2 files changed, 29 insertions(+) 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"); diff --git a/guestfish.pod b/guestfish.pod index 746922f..b464c71 100644 --- a/guestfish.pod +++ b/guestfish.pod @@ -189,6 +189,19 @@ but B by a command. For example: Blank lines are also ignored. +=head1 RUNNING COMMANDS LOCALLY + +Any line which starts with a I character is treated as a command +sent to the local shell (C or whatever L uses). +For example: + + !mkdir local + tgz-out /remote local/remote-data.tar.gz + +will create a directory C on the host, and then export +the contents of C on the mounted filesystem to +C. (See C). + =head1 COMMANDS =head2 help -- 1.8.3.1