From 88a482dd9f6f1b842350edd0437dfe621ebcf510 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Mon, 13 Oct 2014 13:07:43 +0200 Subject: [PATCH] v2v: Add 'exit' choice to --root ask. If the user does ^C then this leaves temporary overlay files around (possibly a bug?). Offer an 'exit' choice to the user which exits cleanly. The new message looks like this: Dual- or multi-boot operating system detected. Choose the root filesystem that contains the main operating system from the list below: [1] /dev/sda3 (Fedora release 20 (Heisenbug)) [2] /dev/sdb3 Enter a number between 1 and 2, or 'exit': exit --- v2v/v2v.ml | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/v2v/v2v.ml b/v2v/v2v.ml index fdb57355c..7b109901d 100644 --- a/v2v/v2v.ml +++ b/v2v/v2v.ml @@ -417,7 +417,7 @@ and inspect_source g root_choice = | `Ask -> (* List out the roots and ask the user to choose. *) printf "\n***\n"; - printf (f_"dual- or multi-boot operating system detected. Choose the root filesystem\nthat contains the main operating system from the list below:\n"); + printf (f_"Dual- or multi-boot operating system detected. Choose the root filesystem\nthat contains the main operating system from the list below:\n"); printf "\n"; iteri ( fun i root -> @@ -430,11 +430,15 @@ and inspect_source g root_choice = let i = ref 0 in let n = List.length roots in while !i < 1 || !i > n do - printf (f_"Enter number between 1 and %d: ") n; - (try i := int_of_string (read_line ()) - with - | End_of_file -> error (f_"connection closed") - | Failure "int_of_string" -> () + printf (f_"Enter a number between 1 and %d, or 'exit': ") n; + let input = read_line () in + if input = "exit" || input = "q" || input = "quit" then + exit 0 + else ( + try i := int_of_string input + with + | End_of_file -> error (f_"connection closed") + | Failure "int_of_string" -> () ) done; List.nth roots (!i - 1)