Recently while coding a small script with YAD I found a "trap" (anyway for me). I wanted to see the return codes of the buttons that were clicked, so inserted an "echo $?" right after the YAD code. That was a mistake, the echo will show the return code, but at the same time it resets it to zero. The result is none of your "case" or "if" code will work correctly. The code below is an example.
Hope this might keep someone else from wasting time (took me almost a day to figure it out) on the same thing.
Thanks
wizard
Code: Select all
#! /bin/bash
values=( $(yad --form --width=400 --title=" " --text="Please enter your info:" --separator=' ' \
--button=Skip:1 \
--button=Apply:0 \
--field="Username" \
--field="Password" \ ))
echo $? #do not do this, it resets $? to zero
ret=$? #this is ok
echo $ret #this is ok