[gparted] Remove one level of quoting when spawning commands
- From: Curtis Gedak <gedakc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gparted] Remove one level of quoting when spawning commands
- Date: Sat, 19 Mar 2011 17:25:56 +0000 (UTC)
commit ba28423e7625629eb5e72f7f57e4c40dae191c1e
Author: Curtis Gedak <gedakc gmail com>
Date: Sat Mar 19 11:24:26 2011 -0600
Remove one level of quoting when spawning commands
Change spawn_command_line_sync to spawn_sync to reduce the level of
quoting required when passing commands to the function. Since
spawn_command_line_sync uses the parent's environment, the replacement
call also uses the parent's environment.
This change permits unmounting of file systems mounted with an
apostrophe in the mount point name.
Ubuntu launchpad bug 151796 - Can't unmount partition with apostrophe
in label
https://bugs.launchpad.net/ubuntu/+source/gparted/+bug/151796
src/Utils.cc | 43 ++++++++++++++++++++++++++++---------------
1 files changed, 28 insertions(+), 15 deletions(-)
---
diff --git a/src/Utils.cc b/src/Utils.cc
index 5e32783..7c419d8 100644
--- a/src/Utils.cc
+++ b/src/Utils.cc
@@ -1,5 +1,5 @@
/* Copyright (C) 2004 Bart 'plors' Hakvoort
- * Copyright (C) 2008, 2009, 2010 Curtis Gedak
+ * Copyright (C) 2008, 2009, 2010, 2011 Curtis Gedak
*
* 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
@@ -277,27 +277,40 @@ int Utils::execute_command( const Glib::ustring & command,
try
{
+ std::vector<std::string>argv;
+ argv .push_back( "sh" ) ;
+ argv .push_back( "-c" ) ;
+ argv .push_back( command ) ;
+
if ( use_C_locale )
{
- std::vector<std::string> envp, argv;
+ //Spawn command using the C language environment
+ std::vector<std::string> envp ;
envp .push_back( "LC_ALL=C" ) ;
envp .push_back( "PATH=" + Glib::getenv( "PATH" ) ) ;
- argv .push_back( "sh" ) ;
- argv .push_back( "-c" ) ;
- argv .push_back( command ) ;
-
- Glib::spawn_sync( ".",
- argv,
- envp,
- Glib::SPAWN_SEARCH_PATH,
- sigc::slot<void>(),
- &std_out,
- &std_error,
- &exit_status ) ;
+ Glib::spawn_sync( "."
+ , argv
+ , envp
+ , Glib::SPAWN_SEARCH_PATH
+ , sigc::slot<void>()
+ , &std_out
+ , &std_error
+ , &exit_status
+ ) ;
}
else
- Glib::spawn_command_line_sync( "sh -c '" + command + "'", &std_out, &std_error, &exit_status ) ;
+ {
+ //Spawn command inheriting the parent's environment
+ Glib::spawn_sync( "."
+ , argv
+ , Glib::SPAWN_SEARCH_PATH
+ , sigc::slot<void>()
+ , &std_out
+ , &std_error
+ , &exit_status
+ ) ;
+ }
}
catch ( Glib::Exception & e )
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]