I need to make a little search form to find some titles in a db. I use dialog form from bash. The problem is that i can't get empty string when the form's field is not filled.
function searchEngine() {
exec 3>&1
"ENGINE=($(dialog --clear --ok-label "Submit" \
--title "Search Engine" \
--form "Search" \
15 50 0 \
"1 :" 1 1 "${ENGINE[0]} " 1 20 30 0 \
"2 :" 2 1 "${ENGINE[1]} " 2 20 30 0 \
"3 :" 3 1 "${ENGINE[2]} " 3 20 30 0 \
"4 :" 4 1 "${ENGINE[3]} " 4 30 20 0 \
2>&1 1>&3))"
exec 3>&-
}
echo "${ENGINE[*]}"
If 3 and 2 is not filled, ENGINE[0]=smthg ENGINE[1]=smthg ${#ENGINE[@]}=2 I need empty string for field not filled. Thanks in advance
Add this at the bottom of your function:
Change
function searchEngine() {
to justsearchEngine() {
by the way as adding that superfluousfunction
keyword just makes it non-portable to other shells.