Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend show_infobox to skip dialog if terminal is not defined #156

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 27 additions & 20 deletions lib/armbian-configng/config.ng.functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -678,28 +678,35 @@ module_options+=(
# Function to display an infobox with a message
#
function show_infobox() {
export TERM=ansi
local input
local BACKTITLE="$BACKTITLE"
local -a buffer # Declare buffer as an array
if [ -p /dev/stdin ]; then
while IFS= read -r line; do
buffer+=("$line") # Add the line to the buffer
# If the buffer has more than 10 lines, remove the oldest line
if ((${#buffer[@]} > 18)); then
buffer=("${buffer[@]:1}")
fi
# Display the lines in the buffer in the infobox

TERM=ansi $DIALOG --title "$TITLE" --infobox "$(printf "%s\n" "${buffer[@]}")" 16 90
sleep 0.5
done
else
local input="$1"
local -a buffer # Declare buffer as an array
if [ -p /dev/stdin ]; then
while IFS= read -r line; do
buffer+=("$line") # Add the line to the buffer
# If the buffer has more than 10 lines, remove the oldest line
if ((${#buffer[@]} > 18)); then
buffer=("${buffer[@]:1}")
fi
if [ -t 0 ]; then
# Display the lines in the buffer in the infobox
$DIALOG --title "$TITLE" --infobox "$(printf "%s\n" "${buffer[@]}")" 16 90
else
# Terminal not defined - proceed without TUI
printf "%s\n" "${buffer[@]}"
fi
sleep 0.5
done
else

input="$1"
TERM=ansi $DIALOG --title "$TITLE" --infobox "$input" 6 80
fi
echo -ne '\033[3J' # clear the screen
if [ -t 0 ]; then
TERM=ansi $DIALOG --title "$TITLE" --infobox "$input" 6 80
else
# Terminal not defined - proceed without TUI
echo $input
fi
fi
echo -ne '\033[3J' # clear the screen
}

module_options+=(
Expand Down
3 changes: 3 additions & 0 deletions tests/S01.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ENABLED=true
PREINSTALL="apt install linux-image-current-x86; apt-mark hold linux-image-current-x86"
CONDITION=""