Why is the "tput col" number changing while running bash script in terminal emulator?
I seem to have run into new situation and I'm hoping someone can explain this to me please.
I know it can change if I increase or decrease the terminal emulator via mouse for example.
However i notices that the number changes to 80 no matter if I'm in terminator or xfce4-terminal
and only after a redirect to a file such as when i make copies of stderr. Why exactly 80 and not 86, 107 etc.
I'm using Xubuntu 14.04 on a 1920x1080 resolution.
In the script I wish to output a space in the amount of "tput col" and it outputs only 80 which troughs of the beginning of a new line.
like in this function
Code:
#!/bin/bash
function Check_AccuracYN { # 06 - SIX ##
##################################################################################
# Correct order is FIRST [$1 = Y/N Answer] and SECOND [ $2 = Question]
AccuracyAnswer=""; AccuracyAnswer="$1"
AccuracyQuestion=""; AccuracyQuestion="$2"
if [[ "$AccuracyAnswer" != [y/n] ]]; then echo "a"; echo "b"; fi
while [[ "$AccuracyAnswer" != [y/n] ]]; do
echo -e "\e[2A$WrongInput"
MaxRowLengh=$(tput cols) && printf '%0.s ' $(seq 1 $MaxRowLengh)
echo -en "\e[1A$AccuracyQuestion"; read AccuracyAnswer
done
##################################################################################
};
The goal would be not to create a endless amount of additional lines with repeated error messages.
By the way this code does work properly when tested by it self.
Thanks for your help.
Bookmarks