Registered Member
|
I would like to get to know about both the kdialog's exit code and the returned value.
My usage case is that of using it in shell scripting, like this: declare variable=`kdialog --title"some title" --kindOfDialog someKind` Then I need to either exit with error if the dialog was canceled or continue if it was ok. But #? is 0 always (the assignment is ok), and the value entered in the dialog can be the empty string.
Nihil difficile volenti
|
Global Moderator
|
Hmm, I'm not sure I understand your problem. For me the exit status of the dialog is 0 if it succeeds, else 1, and the text entered is written to stdout. Doesn't it work like that for you?
Greetings, Sven
I'm working on the KDevelop IDE.
|
Registered Member
|
Yes, it behaves exactly like you sayd. That is the problem:
declare theResult=`kdialog .....` if [ $? ]; then # what to do if kdialog was cancelled kdialog --error "You can not cancel to proceed" exit 1 fi #do something more exit 0 The former script does not exits with exitcode 1. I assume it's because the last command executed is the assignment, and it is succesfull.
Nihil difficile volenti
|
Registered Member
|
Remove that "declare", then it should work... |
Registered Member
|
It works only in the shell command line.
Sample: $ var=$(kdialog --combobox "Select one:" "alfa" "omega" --default "alfa") #here you should press on cancel $ echo $? 1 $ var=$(kdialog --combobox "Select one:" "alfa" "omega" --default "alfa") #now on ok $echo $? 0 Now, i don't get to a simple: if [ $? ]; then echo "ok"; else echo "cancel"; fi which happens to go the else branch
Nihil difficile volenti
|
Global Moderator
|
I'm working on the KDevelop IDE.
|
Registered Member
|
done by keeping the $? in a named variable
declare proceed declare version version=`kdialog --title "Version selection" --combobox "Select a version:" "trunk" "stable" --default "trunk"` proceed=$? if [ ${proceed} -eq 1 ]; then exit 1 fi unset proceed
Nihil difficile volenti
|
Registered Member
|
Well, it works fine here without that. And you don't really need to declare your variables. (although you can if you want to of course...) This works fine for me:
|
Registered Member
|
Just put exit at the end of your Bash or SH-Skript after eyerything is done or if the user dont choose the variables or your programm did not create the file you wisch:
Examples file-there fileth=$(find xyz -type f) if [ "$fileth" = '' ]; then kdialog --msgbox "Sorry Error bla bla" exit 1 fi target=$(kdialog --combobox "<font size=5>Choos suffix<font>" "mpg" "mp4" "avi" "DVD") ### the next if means (if usr do anything but choosing the offered variables (mp4, avi, DVD etc) if [[ $target == '' ]]; then kdialog --msgbox "<font size=6> Thanks for not choosing any thing, Goodbey <dont>" exit fi if [ "$target" = mpg ]; then bla bla fi exit |
Registered users: Bing [Bot], Google [Bot], Sogou [Bot]