summaryrefslogtreecommitdiffstats
path: root/fish/guestfish.pod
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2011-01-18 11:46:03 +0000
committerRichard W.M. Jones <rjones@redhat.com>2011-01-18 13:16:28 +0000
commitc3887285abbb3606822626ba396a51cb5df80d43 (patch)
tree6710d2b44d0cd9268ad78fc7718b7c4483a63575 /fish/guestfish.pod
parent61a4db138e4f85033c655bf6b24df0949683c24c (diff)
downloadlibguestfs-c3887285abbb3606822626ba396a51cb5df80d43.tar.gz
libguestfs-c3887285abbb3606822626ba396a51cb5df80d43.tar.xz
libguestfs-c3887285abbb3606822626ba396a51cb5df80d43.zip
fish: <! cmd executes a shell command and inlines the resulting commands.
The new guestfish construct "<! cmd" executes the shell command "cmd", and then anything printed to stdout by "cmd" is parsed and executed as a guestfish command. This allows some very hairy shell scripting with guestfish.
Diffstat (limited to 'fish/guestfish.pod')
-rw-r--r--fish/guestfish.pod26
1 files changed, 26 insertions, 0 deletions
diff --git a/fish/guestfish.pod b/fish/guestfish.pod
index 21f25bd8..5ec6689e 100644
--- a/fish/guestfish.pod
+++ b/fish/guestfish.pod
@@ -676,6 +676,32 @@ C<local/remote-data.tar.gz>. (See C<tgz-out>).
To change the local directory, use the C<lcd> command. C<!cd> will
have no effect, due to the way that subprocesses work in Unix.
+=head2 LOCAL COMMANDS WITH INLINE EXECUTION
+
+If a line starts with I<E<lt>!> then the shell command is executed (as
+for I<!>), but subsequently any output (stdout) of the shell command
+is parsed and executed as guestfish commands.
+
+Thus you can use shell script to construct arbitrary guestfish
+commands which are then parsed by guestfish.
+
+For example it is tedious to create a sequence of files
+(eg. C</foo.1> through C</foo.100>) using guestfish commands
+alone. However this is simple if we use a shell script to
+create the guestfish commands for us:
+
+ <! for n in `seq 1 100`; do echo write /foo.$n $n; done
+
+or with names like C</foo.001>:
+
+ <! for n in `seq 1 100`; do printf "write /foo.%03d %d\n" $n $n; done
+
+When using guestfish interactively it can be helpful to just run the
+shell script first (ie. remove the initial C<E<lt>> character so it is
+just an ordinary I<!> local command), see what guestfish commands it
+would run, and when you are happy with those prepend the C<E<lt>>
+character to run the guestfish commands for real.
+
=head1 PIPES
Use C<command E<lt>spaceE<gt> | command> to pipe the output of the