summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthew Booth <mbooth@redhat.com>2009-09-11 09:27:57 +0100
committerMatthew Booth <mbooth@redhat.com>2009-09-14 13:59:01 +0100
commit22cee80bc2f631703bf417a54ef4e0f0837e921a (patch)
treefd9be63f3951303c5d6f22ab9651f0d2598dfda7 /src
parentf8eb7a18f859fc778d06b9c3f0cafedbeba1e47f (diff)
downloadlibguestfs-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 'src')
-rwxr-xr-xsrc/generator.ml3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/generator.ml b/src/generator.ml
index 71aeeed8..fa08688b 100755
--- a/src/generator.ml
+++ b/src/generator.ml
@@ -6362,7 +6362,8 @@ and generate_fish_cmds () =
pr " %s = strcmp (argv[%d], \"-\") != 0 ? argv[%d] : \"/dev/stdout\";\n"
name i i
| StringList name | DeviceList name ->
- pr " %s = parse_string_list (argv[%d]);\n" name i
+ pr " %s = parse_string_list (argv[%d]);\n" name i;
+ pr " if (%s == NULL) return -1;\n" name;
| Bool name ->
pr " %s = is_true (argv[%d]) ? 1 : 0;\n" name i
| Int name ->