Results 1 to 7 of 7

Thread: 'tput col' number changes in bash script

Threaded View

  1. #1
    Join Date
    Oct 2011
    Location
    Sacramento, California
    Beans
    40
    Distro
    Xubuntu 14.04 Trusty Tahr

    'tput col' number changes in bash script

    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.
    Last edited by octius4u; June 19th, 2014 at 05:39 AM. Reason: additional info

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •