diff options
-rw-r--r-- | parted/ui.c | 5 | ||||
-rwxr-xr-x | tests/t0000-basic.sh | 1 | ||||
-rwxr-xr-x | tests/t1100-busy-label.sh | 1 | ||||
-rwxr-xr-x | tests/t2000-mkfs.sh | 23 |
4 files changed, 29 insertions, 1 deletions
diff --git a/parted/ui.c b/parted/ui.c index fb311e2..58e4563 100644 --- a/parted/ui.c +++ b/parted/ui.c @@ -32,6 +32,7 @@ #include "command.h" #include "strlist.h" #include "ui.h" +#include "error.h" #define N_(String) String #if ENABLE_NLS @@ -866,11 +867,15 @@ command_line_get_word (const char* prompt, const char* def, return result; result_node = str_list_match (possibilities, result); + if (result_node == NULL) + error (0, 0, _("invalid token: %s"), result); free (result); if (result_node) return str_list_convert_node (result_node); command_line_flush (); + if (opt_script_mode) + return NULL; } command_line_prompt_words (prompt, def, possibilities, diff --git a/tests/t0000-basic.sh b/tests/t0000-basic.sh index f7a0c67..35bf6e6 100755 --- a/tests/t0000-basic.sh +++ b/tests/t0000-basic.sh @@ -85,6 +85,7 @@ fail=0 cat <<EOF >> exp || fail=1 Warning: The existing disk label on DEVICE will be destroyed and all\ data on this disk will be lost. Do you want to continue? +parted: invalid token: msdos Yes/No? y New disk label type? [msdos]? EOF diff --git a/tests/t1100-busy-label.sh b/tests/t1100-busy-label.sh index b1f1659..d571ae1 100755 --- a/tests/t1100-busy-label.sh +++ b/tests/t1100-busy-label.sh @@ -68,6 +68,7 @@ test_expect_failure \ fail=0 cat <<EOF > exp || fail=1 Warning: Partition(s) on $dev are being used. +parted: invalid token: msdos Ignore/Cancel? c EOF test_expect_success 'create expected output file' 'test $fail = 0' diff --git a/tests/t2000-mkfs.sh b/tests/t2000-mkfs.sh index 79d327e..fb39815 100755 --- a/tests/t2000-mkfs.sh +++ b/tests/t2000-mkfs.sh @@ -33,7 +33,7 @@ test_expect_success \ test_expect_success 'expect no output' '$compare out /dev/null' test_expect_success \ - 'create an partition' \ + 'create a partition' \ 'parted -s $dev mkpart primary 1 40 > out 2>&1' test_expect_success \ @@ -80,4 +80,25 @@ test_expect_success \ "data on the partition will be lost. Do you want to continue?" > exp && $compare out2 exp' +############################################################# +# Ensure that an invalid file system type elicits a diagnostic. +# Before parted 1.8.8, this would fail silently. + +dev=loop-file + +test_expect_success \ + "setup: create and label a device" \ + 'dd if=/dev/zero of=$dev bs=1M count=1 2>/dev/null && + parted -s $dev mklabel msdos' + +test_expect_failure \ + 'try to create a file system with invalid type name' \ + 'parted -s $dev mkpartfs primary bogus 1 1 >out 2>&1' + +test_expect_success \ + 'check for expected diagnostic' \ + '{ echo "parted: invalid token: bogus" + echo "Error: Expecting a file system type."; } > exp && + $compare out exp' + test_done |