From c80647fd37a9eced831bd3532f85ea074fa14900 Mon Sep 17 00:00:00 2001 From: Richard Jones Date: Sat, 20 Mar 2010 14:34:55 +0000 Subject: [PATCH] Update simple example. --- examples/simple/.gitignore | 1 + examples/simple/20-shell.sh | 6 +++--- examples/simple/30-goodbye.html | 12 +++++++++++- examples/simple/functions | 15 ++++++++++----- 4 files changed, 25 insertions(+), 9 deletions(-) create mode 100644 examples/simple/.gitignore diff --git a/examples/simple/.gitignore b/examples/simple/.gitignore new file mode 100644 index 0000000..da78adf --- /dev/null +++ b/examples/simple/.gitignore @@ -0,0 +1 @@ +history \ No newline at end of file diff --git a/examples/simple/20-shell.sh b/examples/simple/20-shell.sh index 7cbea33..eacada8 100755 --- a/examples/simple/20-shell.sh +++ b/examples/simple/20-shell.sh @@ -1,5 +1,5 @@ #!/bin/bash - source functions -add_history guestfish -a vm1.img -add_history guestfish -a vm2.img -m /dev/sda1 -terminal --title="Guestfish demonstration" +add_history echo History command number 2 +add_history echo '"History command number 1"' +terminal --title="Press the UP ARROW to get history" diff --git a/examples/simple/30-goodbye.html b/examples/simple/30-goodbye.html index 51dcab3..2225729 100644 --- a/examples/simple/30-goodbye.html +++ b/examples/simple/30-goodbye.html @@ -6,11 +6,21 @@ Goodbye, hope you enjoyed this simple example.

-Now look at these files to find out how we did it: +We hope you noticed on the previous slide that you +could hit the Up arrow to get pre-populated +history. +

+ +

+Now look at these files in the current directory +to find out how we did it:

diff --git a/examples/simple/functions b/examples/simple/functions index cb34080..c8df6e7 100644 --- a/examples/simple/functions +++ b/examples/simple/functions @@ -1,14 +1,14 @@ # -*- shell-script -*- -# Need a short sleep to allow the previous shell to exit, possibly -# writing to the history file, before we start the new shell. Could -# write to a different history file each time which would avoid this. -sleep 1 +# Place any local environment variables required in 'local'. +if [ -f local ]; then source local; fi export PS1="$ " -export HISTFILE=/tmp/history + +export HISTFILE=$talkdir/history rm -f $HISTFILE +touch $HISTFILE add_history () { @@ -17,6 +17,11 @@ add_history () terminal () { + # Make $HISTFILE unwritable so the shell won't update it + # when it exits. + chmod -w $HISTFILE + + # Run gnome-terminal. exec \ gnome-terminal \ --window \ -- 1.8.3.1