[parted-devel] [PATCH] Skip all the interaction with the use if we are in script mode.

Joel Andres Granados jgranado at redhat.com
Wed Jun 18 11:26:57 UTC 2008


---
 parted/parted.c |   86 ++++++++++++++++++++++++++++++++++---------------------
 1 files changed, 53 insertions(+), 33 deletions(-)

diff --git a/parted/parted.c b/parted/parted.c
index 9f79ea4..81b7805 100644
--- a/parted/parted.c
+++ b/parted/parted.c
@@ -776,23 +776,33 @@ do_mkpart (PedDevice** dev)
                         start_sol = ped_unit_format (*dev, part->geom.start);
                         end_sol   = ped_unit_format (*dev, part->geom.end);
 
-                        switch (ped_exception_throw (
-                                PED_EXCEPTION_WARNING,
-                                PED_EXCEPTION_YES_NO,
-                                _("You requested a partition from %s to %s.\n"
-                                  "The closest location we can manage is "
-                                  "%s to %s.  "
-                                  "Is this still acceptable to you?"),
-                                start_usr, end_usr, start_sol, end_sol))
-                        {
-                                case PED_EXCEPTION_YES:
-                                        /* all is well in this state */
-                                        break;
-                                case PED_EXCEPTION_NO:
-                                case PED_EXCEPTION_UNHANDLED:
-                                default:
-                                        /* undo partition addition */
-                                        goto error_remove_part;
+                        if(!opt_script_mode){
+                                switch (ped_exception_throw (
+                                        PED_EXCEPTION_WARNING,
+                                        PED_EXCEPTION_YES_NO,
+                                        _("You requested a partition from %s to %s.\n"
+                                          "The closest location we can manage is "
+                                          "%s to %s.  "
+                                          "Is this still acceptable to you?"),
+                                        start_usr, end_usr, start_sol, end_sol))
+                                {
+                                        case PED_EXCEPTION_YES:
+                                                /* all is well in this state */
+                                                break;
+                                        case PED_EXCEPTION_NO:
+                                        case PED_EXCEPTION_UNHANDLED:
+                                        default:
+                                                /* undo partition addition */
+                                                goto error_remove_part;
+                                }
+                        } else {
+                                ped_exception_throw (
+                                        PED_EXCEPTION_WARNING,
+                                        PED_EXCEPTION_OK,
+                                        _("You requested a partition from %s to %s.\n"
+                                        "The closest location we can manage is "
+                                        "%s to %s."),
+                                        start_usr, end_usr, start_sol, end_sol);
                         }
                 } else {
                         goto error_remove_part;
@@ -936,22 +946,32 @@ do_mkpartfs (PedDevice** dev)
                         start_sol = ped_unit_format (*dev, part->geom.start);
                         end_sol   = ped_unit_format (*dev, part->geom.end);
 
-                        switch (ped_exception_throw (
-                                PED_EXCEPTION_WARNING,
-                                PED_EXCEPTION_YES_NO,
-                                _("You requested a partition from %s to %s.\n"
-                                  "The closest location we can manage is "
-                                  "%s to %s.  "
-                                  "Is this still acceptable to you?"),
-                                start_usr, end_usr, start_sol, end_sol)) {
-                                case PED_EXCEPTION_YES:
-                                        /* all is well in this state */
-                                        break;
-                                case PED_EXCEPTION_NO:
-                                case PED_EXCEPTION_UNHANDLED:
-                                default:
-                                        /* undo partition addition */
-                                        goto error_remove_part;
+                        if(!opt_script_mode){
+                                switch (ped_exception_throw (
+                                        PED_EXCEPTION_WARNING,
+                                        PED_EXCEPTION_YES_NO,
+                                        _("You requested a partition from %s to %s.\n"
+                                          "The closest location we can manage is "
+                                          "%s to %s.  "
+                                          "Is this still acceptable to you?"),
+                                        start_usr, end_usr, start_sol, end_sol)) {
+                                        case PED_EXCEPTION_YES:
+                                                /* all is well in this state */
+                                                break;
+                                        case PED_EXCEPTION_NO:
+                                        case PED_EXCEPTION_UNHANDLED:
+                                        default:
+                                                /* undo partition addition */
+                                                goto error_remove_part;
+                                }
+                        } else {
+                                ped_exception_throw (
+                                        PED_EXCEPTION_WARNING,
+                                        PED_EXCEPTION_OK,
+                                        _("You requested a partition from %s to %s.\n"
+                                        "The closest location we can manage is "
+                                        "%s to %s."),
+                                        start_usr, end_usr, start_sol, end_sol);
                         }
                 } else {
                         goto error_remove_part;
-- 
1.5.4.1




More information about the parted-devel mailing list