metal3d / bashsimplecurses

A simple curses library made in bash to draw terminal interfaces
BSD 3-Clause "New" or "Revised" License
921 stars 115 forks source link

initialize global variables at the begining #68

Closed shyjun closed 3 months ago

shyjun commented 3 months ago

a simple app which just want to show some data in a list fails due to some of the variables are not initialized. to overcome this initialize the vars in the begining

here is an example script which fails without this fix. comments starting with # are marked as # in this

#!/bin/bash

source ../bashsimplecurses/simple_curses.sh

file=main.c

command_output() { # Capture the output of the command output=$(find ./ -name $file* | grep -v ".git"| cat -n) # Display the output in the window echo "$output" }

show_win() { # Initialize the screen window "window" "blue" count=find ./ -name $file* | grep -v "\.git"| wc -l append "total numbers: $count" addsep # Call the command_output function to display the content append_command "command_output" # Display the window endwin }

# Run the show_win function show_win

echo "done"

metal3d commented 3 months ago

Thanks a lot!