bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Bug in select-command


From: address@hidden
Subject: Bug in select-command
Date: Sat, 24 Jun 2017 13:46:00 +0200

It is necessary to refresh the variable $COLUMNS in a script (COLUMNS="tput 
cols") otherwise the command "select" will not set the number of columns 
correctly for actual screen resolution.

Information:            checkwinsize    on

Please try this script-example to see the effect:
#!/bin/bash

### SET VARIABLES ###
        PS3="Select: "


# EXECUTE THE SCRIPT WITH THE NEXT LINE (correctly set number of columns) AND 
WITHOUT (just 2 columns) TO SEE THE EFFECT !!!
        COLUMNS="$(tput cols)"


### DEFINE PRE-FUNCTIONS ###
echo() { builtin echo -e "$@" ;}
read() { builtin read -re "$@" ;}
bc() { echo "scale=2;$1" | $(which bc) -l ;}

### DEFINE FUNCTIONS ###
_config-keymap() {
        # Select keymap
                # find keymap list, cut directory path and sort
                        local list_keymaps=( $(find /usr/share/kbd/keymaps/ 
-type f -name 
*.map.gz | grep -Eo [^/]*.map.gz | sort -V) )
                # cut suffixes
                        list_keymaps=( ${list_keymaps[@]%%.*} )

                select locale_keymap in ${list_keymaps[@]}; do
                        if [[ "$REPLY" -ge 1 && "$REPLY" -lt 
${#list_keymaps[@]} ]]; then
                                echo ${locale_keymap}; break
                        fi
                done
}

### MAIN PROGRAMM ###
clear
_config-keymap



reply via email to

[Prev in Thread] Current Thread [Next in Thread]