diff options
author | Matthew Booth <mbooth@redhat.com> | 2009-09-11 09:27:57 +0100 |
---|---|---|
committer | Matthew Booth <mbooth@redhat.com> | 2009-09-14 13:59:01 +0100 |
commit | 22cee80bc2f631703bf417a54ef4e0f0837e921a (patch) | |
tree | fd9be63f3951303c5d6f22ab9651f0d2598dfda7 /regressions | |
parent | f8eb7a18f859fc778d06b9c3f0cafedbeba1e47f (diff) | |
download | libguestfs-22cee80bc2f631703bf417a54ef4e0f0837e921a.tar.gz libguestfs-22cee80bc2f631703bf417a54ef4e0f0837e921a.tar.xz libguestfs-22cee80bc2f631703bf417a54ef4e0f0837e921a.zip |
guestfish: Enable grouping in string lists
This change adds the ability to group entries in a string list with single
quotes. So the string:
"'foo bar'"
becomes 1 token rather than 2. Consequently single quotes must now be escaped:
"\'"
resolves to a literal single quote.
Incidentally, this change also alters another, probably unintentional behaviour
of the previous implementation, in that tokens are separated by any amount of
whitespace rather than a single whitespace character. I.e.:
"a b"
resolves to:
'a' 'b'
rather than:
'a' '' 'b'
That last syntax can be used if an empty argument is still desired. Whitespace
is now also defined to include tabs.
parse_string_list can also now fail if it contains an unmatched open quote.
Diffstat (limited to 'regressions')
-rw-r--r-- | regressions/Makefile.am | 3 | ||||
-rwxr-xr-x | regressions/test-stringlist.sh | 60 |
2 files changed, 62 insertions, 1 deletions
diff --git a/regressions/Makefile.am b/regressions/Makefile.am index 3279f95c..9112b94d 100644 --- a/regressions/Makefile.am +++ b/regressions/Makefile.am @@ -32,7 +32,8 @@ TESTS = \ test-qemudie-synch.sh \ test-read_file.sh \ test-remote.sh \ - test-reopen.sh + test-reopen.sh \ + test-stringlist.sh SKIPPED_TESTS = \ test-bootbootboot.sh diff --git a/regressions/test-stringlist.sh b/regressions/test-stringlist.sh new file mode 100755 index 00000000..0b0c476e --- /dev/null +++ b/regressions/test-stringlist.sh @@ -0,0 +1,60 @@ +#!/bin/sh - +# libguestfs +# Copyright (C) 2009 Red Hat Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +# Test remote control of guestfish. + +set -e + +rm -f test.img + +eval `../fish/guestfish --listen` + +error=0 + +function check_echo { + test=$1 + expected=$2 + + local echo + + echo=$(../fish/guestfish --remote echo_daemon "$test") + if [ "$echo" != "$expected" ]; then + echo "Expected \"$expected\", got \"$echo\"" + error=1 + fi +} + +../fish/guestfish --remote alloc test.img 10M +../fish/guestfish --remote run + +check_echo "' '" " " +check_echo "\'" "'" +check_echo "'\''" "'" +check_echo "'\' '" "' " +check_echo "'\'foo\''" "'foo'" +check_echo "foo' 'bar" "foo bar" +check_echo "foo' 'bar" "foo bar" +check_echo "'foo' 'bar'" "foo bar" +check_echo "'foo' " "foo" +check_echo " 'foo'" "foo" + +../fish/guestfish --remote exit + +rm -f test.img + +exit $error |