From e297fe64e6b093a43598ae7274c015d8433f686a Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Sun, 22 Sep 2024 19:25:32 +0300 Subject: [PATCH] Fix to control terminal echo silently --- slib.sh | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/slib.sh b/slib.sh index 08d2ee8..a6f4680 100644 --- a/slib.sh +++ b/slib.sh @@ -9,7 +9,7 @@ #------------------------------------------------------------------------------ cleanup () { exit_code=$1 - stty echo + stty echo 1>/dev/null 2>&1 echo # Make super duper sure we reap all the spinners # This is ridiculous, and I still don't know why spinners stick around. @@ -346,7 +346,7 @@ run_ok () { CHECK='\u2714' BALLOT_X='\u2718' if [ "${INTERACTIVE_MODE}" != "off" ];then - stty -echo + stty -echo 1>/dev/null 2>&1 spinner & spinpid=$! allpids="$allpids $spinpid" @@ -358,7 +358,7 @@ run_ok () { env sleep .4 # It's possible to have a race for stdout and spinner clobbering the next bit # Just in case the spinner survived somehow, kill it. if [ "${INTERACTIVE_MODE}" != "off" ];then - stty echo + stty echo 1>/dev/null 2>&1 pidcheck=$(ps --no-headers ${spinpid}) if [ -n "$pidcheck" ]; then echo "$log_pref Made it here...why?" >> ${RUN_LOG} @@ -423,21 +423,21 @@ yesno () { echo "Never run this script on a system already running Virtualmin." return 1 fi - stty echo + stty echo 1>/dev/null 2>&1 while read -r line; do - stty -echo + stty -echo 1>/dev/null 2>&1 case $line in y|Y|Yes|YES|yes|yES|yEs|YeS|yeS) return 0 ;; n|N|No|NO|no|nO) return 1 ;; *) - stty echo + stty echo 1>/dev/null 2>&1 printf "\\n${YELLOW}Please enter ${CYAN}[y]${YELLOW} or ${CYAN}[n]${YELLOW}:${NORMAL} " ;; esac done - stty -echo + stty -echo 1>/dev/null 2>&1 } # mkdir if it doesn't exist @@ -478,9 +478,9 @@ detect_ip () { else log_warning "Unable to determine IP address of primary interface." echo "Please enter the name of your primary network interface: " - stty echo + stty echo 1>/dev/null 2>&1 read -r primaryinterface - stty -echo + stty -echo 1>/dev/null 2>&1 #primaryaddr=`/sbin/ifconfig $primaryinterface|grep 'inet addr'|cut -d: -f2|cut -d" " -f1` primaryaddr=$(/sbin/ip -f inet -o -d addr show dev "$primaryinterface" | head -1 | awk '{print $4}' | head -1 | cut -d"/" -f1) if [ "$primaryaddr" = "" ]; then @@ -521,9 +521,9 @@ set_hostname () { name=$(hostname -f) log_error "Your system hostname $name is not fully qualified." printf "Please enter a fully qualified hostname (e.g.: host.example.com): " - stty echo + stty echo 1>/dev/null 2>&1 read -r line - stty -echo + stty -echo 1>/dev/null 2>&1 else log_debug "Setting hostname to $forcehostname" line=$forcehostname @@ -775,11 +775,11 @@ serial_ok () { # Ask the user for a new serial number and license key get_serial () { printf "${YELLOW}Please enter your serial number or 'GPL': ${NORMAL}" - stty echo + stty echo 1>/dev/null 2>&1 read -r serial_num - stty -echo + stty -echo 1>/dev/null 2>&1 printf "${YELLOW}Please enter your license key or 'GPL': ${NORMAL}" - stty echo + stty echo 1>/dev/null 2>&1 read -r license_key - stty -echo + stty -echo 1>/dev/null 2>&1 }