I have a simple bash script that works as expected on Unbuntu 20 and LMDE 4. However, when I run it on Debian 11, it exits with error:
"choices=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty)" command filed with exit code 127.
I am running it as root but I still get the error. I also checked the code over at www.shellcheck.net and it said everything was good. This is a brand new install of Debian 11.
Any suggestions? I appreciate it.
Here is the code:
#!/bin/bash
# exit when any command fails
set -e
# keep track of the last executed command
trap 'last_command=$current_command; current_command=$BASH_COMMAND' DEBUG
# echo an error message before exiting
trap 'echo "\"${last_command}\" command filed with exit code $?."' EXIT
cmd=(dialog --separate-output --checklist "Select options:" 22 76 16)
options=(1 "Option 1" off # any option can be set to default to "on"
2 "Option 2" off
3 "Option 3" off
4 "Option 4" off)
choices=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty)
clear
for choice in $choices
do
case $choice in
1) ls
echo "First Option"
;;
2) pwd
echo "Second Option"
;;
3) pwd
echo "Third Option"
;;
4) ls -la
echo "Fourth Option"
;;
esac
done