Version: (using KDE Devel) Installed from: Compiled sources Compiler: gcc version 3.2 (Mandrake Linux 9.0 3.2-1mdk) OS: Linux When using --menu (there is already a testcase for this in kdebase/kdialog/test), if you press cancel, you get a blank line (carriage return). Similarly, when using --checklist without --separate-output, and without any defaults, you get a blank line if you press OK. Note that it is fine if you use --separate-output I think that in each case, you should get no output - the semantics of "no selection" are the same, and the output should be null, not a carriage return. Note that you _could_ construct a script that relies on the --checklist behaviour, so I'm not so sure it is a good idea to change it, even if it is wrong (Script Incompatible Change?).
Created attachment 2341 [details] fixes for blank lines for --menu and --checklist Per original report, second part of change could break existing scripts.
Subject: kdebase/kdialog CVS commit by faure: Fix for "When using --menu, if you press cancel you get a blank line" Patch by Brad Hards <bhards@bigpond.net.au> - thanks! CCMAIL: 63517-done@bugs.kde.org M +6 -2 kdialog.cpp 1.16 --- kdebase/kdialog/kdialog.cpp #1.15:1.16 @@ -281,5 +281,7 @@ int directCommand(KCmdLineArgs *args) QString result; bool retcode = Widgets::listBox(0, title, text, list, result); + if (1 == retcode) { // OK was selected cout << result.local8Bit().data() << endl; + } return retcode ? 0 : 1; } @@ -302,5 +304,7 @@ int directCommand(KCmdLineArgs *args) unsigned int i; for (i=0; i<result.count(); i++) + if (!result[i].local8Bit().isEmpty()) { cout << result[i].local8Bit().data() << endl; + } exit( retcode ? 0 : 1 ); }