Fix run tdesudo with empty command

This relates to Bug 1494
pull/1/head
Slávek Banko 11 years ago
parent fc829172ee
commit 0fd2e545b7

@ -84,20 +84,18 @@ int main(int argc, char **argv)
bool withIgnoreButton = args->isSet("ignorebutton"); bool withIgnoreButton = args->isSet("ignorebutton");
if (args->isSet("c")) if (args->isSet("c")) {
executable = args->getOption("c"); executable = args->getOption("c");
}
if (args->count()) else {
{ if (args->count()) {
if (executable.isEmpty())
{
command = args->arg(0); command = args->arg(0);
commandlist = TQStringList::split(TQChar(' '), command); commandlist = TQStringList::split(TQChar(' '), command);
executable = commandlist[0]; executable = commandlist[0];
} }
} }
if ((!args->isSet("c")) && (!args->count())) { if (executable.stripWhiteSpace().isEmpty()) {
kdError() << I18N_NOOP("You must provide the name of the executable you want to run as an argument to tdesudo") << endl; kdError() << I18N_NOOP("You must provide the name of the executable you want to run as an argument to tdesudo") << endl;
exit(1); exit(1);
} }

@ -68,7 +68,9 @@ KdeSudo::KdeSudo(TQWidget *parent, const char *name,const TQString& icon, const
TQString runas = args->getOption("u"); TQString runas = args->getOption("u");
TQString cmd; TQString cmd;
if (!args->isSet("c") && !args->count() && (!args->isSet("s"))) if (!(args->isSet("c") && !args->getOption("c").stripWhiteSpace().isEmpty()) &&
!(!args->isSet("c") && args->count()) &&
!args->isSet("s"))
{ {
KMessageBox::information(NULL, i18n("No command arguments supplied!\nUsage: tdesudo [-u <runas>] <command>\nKdeSudo will now exit...")); KMessageBox::information(NULL, i18n("No command arguments supplied!\nUsage: tdesudo [-u <runas>] <command>\nKdeSudo will now exit..."));
noExec = true; noExec = true;

Loading…
Cancel
Save