Home > other >  How to get values in YAD when combining form and button // Exit codes for user-specified buttons
How to get values in YAD when combining form and button // Exit codes for user-specified buttons

Time:12-14

#!/bin/bash

array=$(yad \
--separator="\n" \
--form \
--field="Number":NUM 1 \
--field="Text":TEXT \
--button="b1:1" \
--button="b2:2" \
--button="b3:3" )
echo $?
echo "${array[@]}"

When pressing b1 or b3, the array is empty. Why? How to modify this to get always the answer of NUM- and TEXT-form-field in the array and the button number as $? ?

CodePudding user response:

From the manpage:

Exit codes for user-specified buttons must be specified in command line.
Even exit code mean to print result, odd just return exit code.

So, you need to use even exit codes for your buttons

  • Related