I like to know answers, too. However, some questions are more important to me than others -- we all set priorities.
True enough.
You've pointed me into layers I've never been to before, but am not afraid to explore. I'll chew on that and consider this thread to have run its course. Thanks.
Location: Saint Paul, MN USA / BSD, CentOS, Debian, OS X, Solaris
Posts: 2,288
Thanks Given: 430
Thanked 480 Times in 395 Posts
Hi.
It is not easy to understand code that has been extracted from a larger source. Here is a shell script that drives a portion of the bash-select-code, but rendered in perl so that you can run it. It calculates the rows and columns as bash would for the select. It does not pretty-print the selections, it just does the calculations. It assumes that you have a file that corresponds to the strings you would use with select. It allows a second parameter, the setting for COLUMNS so that you can see the effects of changing that. Here are a few runs with varying files and widths, the last with some arithmetic and logical internal results displayed. Note that the shell script calls the perl script, so that it is easily posted here, however, you can copy/paste the perl code and run it as desired.
producing:
And here it the perl code, p2:
Best wishes ... cheers, drl
COLUMNS might be getting set in /etc/profile or ~/.bashrc or something similar.
Is it meaningfull to set COLUMNS hardcoded to any and every terminal(-window) just so select looks 'pretty'?
AFAIK all the rest of the terminal output depends on that too, as in line breaks and such.
Yes, I know I can save and reset it. But my point was that I was not observing the script to actually inherit from the caller.
Perhaps COLUMNS is not exported, try export COLUMNS before running doit2
If COLUMNS is not set scripts/programs could be using tput cols or similar to query the terminal for it's actual width.
Also see bash shopt checkwinsize, this keeps COLUMNS and LINES updated automatically, this is useful for an xterm where the users could resize the window after the shell has started.
Last edited by Chubler_XL; 04-27-2014 at 10:09 PM..
Is it meaningful to set COLUMNS hardcoded to any and every terminal(-window) just so select looks 'pretty'?
That's a rather loaded question. I don't even know which layout you consider "prettiest" yet.
No, you should not hardcode COLUMNS to make select prettier. Doing this may cause inconsistent, unreliable, or unreadable results across different systems, terminals, and shells.
If the end user wants to hardcode their COLUMNS that's another matter. They'd be the one to know how big their terminal is.
hi i am new to bash scripting ..
i created a bunch of folders but only want the folder names with file1. so i go in and make an array to grab the folders the put in a file then i strip the directories so i just have the folder names i need then i would like to make the menu with a selection... (3 Replies)
A lot of my scripting makes use of the 'select' command to create menu driven input. A typical example of how I use it is as:
somevar=''
PS3='Select one: '
while ]; do
select somevar in $(sqlplus -s $dbuser/$dbpw@mydb <<EOF
set echo off feedback off verify off... (7 Replies)
Hi All,
I need to develop a bash script list “list of files” and able to select if any and set as globe variable in script and use for other function.
I would like to see in menu format.
Example out put
Below are the listed files for database clone
1. Sys.txt
2. abc.txt
3. Ddd.txt... (1 Reply)
I am creating a Select menu with a few options and I would like to create a "better" looking interface than just this:
1) Option 1
2) Option 2
3) Option 3
Instead, I would like something like this:
***********
* Cool Script *
* 1) Option 1 *
* 2) Option 2 *
* 3) Option 3 *... (2 Replies)
Hi,
I am using a select in ksh for a script
#!/bin/ksh
FIRSTLIST='one two three four quit'
PS3='Please select a number: '
select i in $FIRSTLIST ;
do
case $i in
one) print 'this is one' ;;
two) print 'this is 2' ;;
three) print 'this is 3' ;;
four) print... (7 Replies)
Hi All,
I am trying to use the select command & the menu.
below mention is my script
#!/bin/bash
2
3 PS3="Is today your birthday? " #PS3 system variable
4
5 echo "\n"
6
7
8 select menu_selection in YES NO QUIT
9 do
10
11 ... (1 Reply)
Hello everyone.
I am using the select command to build a menu, here is my question:
Is it possible to generate a menu which contains several sections and have a separator between the sections without having a selection number generated in front of the separator?
This is a sample of what I would... (1 Reply)
is there a way I can make the menu list reappear when I use select ?
-----
menulist="Change_title Remove_tag Change_tag Add_line Quit"
select word in $menulist #change_title remove_tag change_tag add_line quit
do
case $word in
# first menu option Change Title
... (9 Replies)
Is there any way to implement a drop down menu selection in bash?
This is on CDLinux which is a very minimal live CD and I am using it to install an image onto a hard drive. Part of that process is the timezone selection. There are just too many timezones to attempt to use the "select" command.... (1 Reply)
Hi all
is menu driven by SELECT can be a dynamic ?
My requirement is that i want SELECT to be created on run time not predefine . The select should be created as per the no of
words in a file
thanks in advance
rawat (2 Replies)