Sponsored Content
Top Forums UNIX for Advanced & Expert Users Bash-Completion, one list shown, the other not. Post 302941220 by sea on Tuesday 14th of April 2015 06:29:17 AM
Old 04-14-2015
Hi Don, the creation of the missing file.list and the naming of the variable section_task3 was just for this sharing, as that file.list was created by the application, not by the bash completion.
Should have placed it outside the function, sorry.
Naming it 3 was a typo, should have been 2, which was corrected while you wrote.

The OPTS (-a -b) are just used as metapher for all the options there are, but its right, should have shorten it to '-c' only, for easier seperation.
Anyhow, the issue is, i want to morph the list of that file (abc def ghi ...) so that each entry of that list starts with letter 'b', as in babc, bdef bghi.

To be honest, i barley understood any of your question that were bash-completion specific, i just copied and modified the file, and played around trying to match/fit my needs.
As:
Quote:
Originally Posted by Don Cragun
It is hard to comment when we don't know what the complete or compgen commands look like and we don't know how COMP_CWORD and the COMP_CWORDS array
Saying: I 'know' it works the way it is, but i dont know why or how exactly...
I thought prev="${COMP_WORDS[COMP_CWORD-1]}" is an integrated expression, similar to vars="${@[${#@}-1]}"

So i've adapted your suggestion, and, at least its not using 'b' as a single letter anymore.
Code:
+ files $ source ./reproducable.bash 
:) files $ XY -c a
a1024  a128   a192   a256   a384   a512   a768   a96    
:) files $ XY -c b

When i try to print the content of section_task2, i get this:
Code:
^C
130 files $ XY -c 


a  b  
130 files $ XY -c a


a1024  a128   a192   a256   a384   a512   a768   a96    
130 files $ XY -c b






bash: XY: Command not found.
127 files $

With this code on top:
Code:
	[ -f file.list ] || printf "%s\n" "section_task2=\"abc def ghi jkg lmn opq rst uvw xyz\"" > file.list
	section_task1="a96 a128 a192 a256 a384 a512 a768 a1024"
	#section_task2="b$(grep section_task2 file.list | sed s,section_task2=,, | sed s,\ ,\nb,)"
	section_task2=$(sed -e '/^section_task2=/!d' -e 's/^[^=]*="//' -e 's/"$//' -e 's/^/b/' -e 's/ /\b/g' file.list)
	set +x
	echo $section_task2 ##; return

Seems section_task2 is empty?

A final word about the use of array while its declared (set) as variable, have a look at the git bash completion, i copied from there.
I'm not saying its a temporary solution, but its working as is. -> never change a running system you dont fully understand Smilie
Yet i have/want to change this behaviour for better user support.

Thank you
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

[tcsh2bash] Tab completion - 'enhanced' equivalent in bash?

I really like tcsh's: set completion='enhanced' because it treats underscores and dash signs the same. I don't have to reach for the shift key when trying to complete files that have underscores. As far as I know, there is nothing like this in bash. Does such a thing exist in bash? If... (2 Replies)
Discussion started by: sarnobat
2 Replies

2. Ubuntu

set completion-ignore-case on doesn't work in bash

completion-ignore-case option doesn't work in my version: /home/user $ echo $BASH_VERSION 3.2.48(1)-release /home/user $ ls -l * -rw-r--r-- 1 user user 0 2009-10-18 00:09 somefile -rw-r--r-- 1 user user 0 2009-10-18 00:09 Somefile /home/user $ set completion-ignore-case on But when I... (2 Replies)
Discussion started by: Sapfeer
2 Replies

3. Shell Programming and Scripting

bash completion

hello, I have been trying for a couple days to figure this out to no avail. I am converting some csh code to bash. I have converted everything except the completion code. #bashrc (I set this alias in my bashrc) alias test='source ${PATH}/test.sh' #${PATH}/test.sh (returns some aliases and... (0 Replies)
Discussion started by: platypuus
0 Replies

4. Shell Programming and Scripting

configure bash completion for multiple possibilities

Hello, Bash completion is great, but there are some features I'd like to change. One thing is the behaviour when there are lots of very similar possibilities. E.g., my directory contains 133 files, from pubmed_result1.txt to pubmed_result133.txt $ ls Lyonprim/p Display all 133... (2 Replies)
Discussion started by: jossojjos
2 Replies

5. Shell Programming and Scripting

Programmable completion for two arguments in bash

Hi there! I have this script which handles bookmarks. Bookmarks are basically a string that point to a certain path, e.g., project -> ~/code/projects/project. Currently I have working completion for the bookmarks: ~ $ m p<Tab> ~ $ m project What I want to implement now is the cd... (0 Replies)
Discussion started by: KevinSjoberg
0 Replies

6. UNIX for Dummies Questions & Answers

Bash Tab Completion Hanging

Hi, I'm having a problem with tab completion at the bash command line. For some reason, whenever I type g<tab>, the terminal will freeze up for 5-10 seconds before asking me if I want to display all 325 possibilities. I thought that maybe it's because of the high number of commands, but I have... (4 Replies)
Discussion started by: Raz716
4 Replies

7. UNIX for Dummies Questions & Answers

Bash-completion on shell script

Hello I want use bash_completion on a script but the information on the internet give me not a solution. The scrip start with "cd" to a direction Than the script do "ls" Than I must give a name of a sub-direction and here I want to use <TAB>, so when I have a direction with the name smith... (2 Replies)
Discussion started by: thailand
2 Replies

8. Shell Programming and Scripting

Bash-Completion, an example

Hello I've followed several bash-completion threads, usualy none were answered, because of obvious reasons. (of which i'm just aware since a day or a few) Non-the-less, because i was writing scripts, i never considered it to be possible to add this functionality. Also, because i though that... (0 Replies)
Discussion started by: sea
0 Replies

9. UNIX for Advanced & Expert Users

Bash-Completion, installed but not applied

Heyas For my project TUI i had prepared bash completion. Bash-completion works, at least if i source that file manualy. However, when i'm installing it, it wont apply, not even for new opened terminals. Allthough i had it working once, i dont get why it doesnt work now. <...> + '' +... (0 Replies)
Discussion started by: sea
0 Replies
ZGREP(1)                                                      General Commands Manual                                                     ZGREP(1)

NAME
zgrep - search possibly compressed files for a regular expression SYNOPSIS
zgrep [ grep_options ] [ -e ] pattern filename... DESCRIPTION
Zgrep invokes grep on compressed or gzipped files. These grep options will cause zgrep to terminate with an error code: (-[drRzZ]|--di*|--exc*|--inc*|--rec*|--nu*). All other options specified are passed directly to grep. If no file is specified, then the standard input is decompressed if necessary and fed to grep. Otherwise the given files are uncompressed if necessary and fed to grep. If the GREP environment variable is set, zgrep uses it as the grep program to be invoked. EXIT CODE
2 - An option that is not supported was specified. AUTHOR
Charles Levert (charles@comm.polymtl.ca) SEE ALSO
grep(1), gzexe(1), gzip(1), zdiff(1), zforce(1), zmore(1), znew(1) ZGREP(1)
All times are GMT -4. The time now is 01:15 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy