From 21cc8cea315af252bef40227c36e9492d6702cb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sl=C3=A1vek=20Banko?= Date: Fri, 27 Sep 2013 01:58:51 +0200 Subject: Fix run tdesu with empty command This relates to Bug 1494 --- tdesu/tdesu/tdesu.cpp | 39 +++++++++++++++------------------------ 1 file changed, 15 insertions(+), 24 deletions(-) (limited to 'tdesu') diff --git a/tdesu/tdesu/tdesu.cpp b/tdesu/tdesu/tdesu.cpp index ede3b4dfd..eb1cbdcf8 100644 --- a/tdesu/tdesu/tdesu.cpp +++ b/tdesu/tdesu/tdesu.cpp @@ -158,7 +158,7 @@ static int startApp() TQString icon; if ( args->isSet("i")) - icon = args->getOption("i"); + icon = args->getOption("i"); bool prompt = true; if ( args->isSet("d")) @@ -218,33 +218,24 @@ static int startApp() } // Get command - if (args->isSet("c")) - { + if (args->isSet("c")) { command = args->getOption("c"); - for (int i=0; icount(); i++) - { - TQString arg = TQFile::decodeName(args->arg(i)); - KRun::shellQuote(arg); - command += " "; - command += TQFile::encodeName(arg); - } } - else - { - if( args->count() == 0 ) - { - TDECmdLineArgs::usage(i18n("No command specified.")); - exit(1); - } - command = args->arg(0); - for (int i=1; icount(); i++) - { - TQString arg = TQFile::decodeName(args->arg(i)); - KRun::shellQuote(arg); - command += " "; - command += TQFile::encodeName(arg); + else { + if( args->count() ) { + command = args->arg(0); } } + if (command.stripWhiteSpace().isEmpty()) { + TDECmdLineArgs::usage(i18n("No command specified.")); + exit(1); + } + for (int i= args->isSet("c") ? 0 : 1; icount(); i++) { + TQString arg = TQFile::decodeName(args->arg(i)); + KRun::shellQuote(arg); + command += " "; + command += TQFile::encodeName(arg); + } // Don't change uid if we're don't need to. if (!change_uid) -- cgit v1.2.3