I have the following bash function that has me boondoggled. If I enter the following in the zenity boxes...
employeeid = 2 categoryid = 3
I get the following: 2 3
if...
employeeid = categoryid = 3
After a second zenity window opens I enter 2 and I get the following: 2 3
However when I enter
employeeid = 2 categoryid =
No additional Zenity window opens and I get the following: 2
What I really want to end up with is 2,3 after the tests have run.
Does anyone know what is wrong here?
#!/bin/bash
num(){
emp=$(echo "$1" | awk -F, -v OFS=, '{print $1 "," $2}')
IFS=, read -ra array1 <<<"$emp"
p=$(for i in "${array1[@]}"
do
if [[ "${i}" =~ ^[0-9]+$ ]]; then
out="${i}"
elif
[[ "${i}" = NULL ]]; then
out="${i}"
else local var2
until [[ ${var2} =~ ^[0-9]+$ ]] || [[ ${var2} = NULL ]]; do
var2="$(zenity --forms --title="table salaries_wages" --text "Add a number" --separator="," \
--add-entry="WARNING! You either forgot to enter or didn't enter a number. Please enter a valid number: ")"
done
out="${var2}"
fi
echo "$out"
done)
echo "$p"
}
input="$(zenity --forms --title="table salaries_wages" --text="Add a new salaries_wages entry" --separator="," \
--add-entry="ENTER employeeid: " \
--add-entry="ENTER categoryid: ")"
num "$input"