pkgsrc-Bugs archive

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

pkg/40705: Bash-completion fails several completions due to not checking for NetBSD in 'uname' output.

>Number:         40705
>Category:       pkg
>Synopsis:       Bash-completion fails several completions due to not checking 
>for NetBSD in 'uname' output.
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Feb 21 00:25:00 +0000 2009
>Originator:     Nick Coleman
>Release:        4.0
NetBSD mac.nick 4.0 NetBSD 4.0 (nick) #4: Sat Oct 18 23:00:39 WST 2008  
root@mac:/usr/src/sys/arch/macppc/compile/nick macppc
Bash-completion-20060301 is a pkgsrc package in shells/.  It is a generic 
script to extend the completion features of Bash, adding completion for many 
commands like man, info, and a range of many others.  It is very useful (e.g. 
necessary) for people who spend a lot of time in a Bash shell.

It has been written to use the output of 'uname' to check for the existence of 
commands in different OSs, and to check and allow for different versions of 
commands (e.g. Solaris vs GNU).  The script does not allow for "NetBSD" as a 
match in uname and consequently many functions exit without performing the 
completion as they fail the OS test at the beginning of the relevent function.

The uname checks occur frequently throughout the script.  The problem has been 
reported on the Debian bug tracker: 
and the comments there are worth reading for a good description of the full 
extent of the problem, and some suggested fixes.  In precis, they suggest the  
uname checks should be removed and changed to something like (paraphrase) [ -f 
command ] plus [ ${command -version} || ${command --version} ] or similar.

Attempt to tab complete a 'man' command.  The completion will fail, as man is 
one of the functions that tests uname to check for the OS type and will fail 
since "NetBSD" is not tested.  See function _man() in bash_completion.

There are many other commands that also fail.  I have not tested them all since 
the bug is a logic one applicable to any function that uses uname.

FYI, FreeBSD and OpenBSD work correctly as their strings are included in the 
In order of difficulty of fix:

1) For the NetBSD package, add NetBSD to every instance of a uname test in 
bash_completion and the scripts in the contrib directory.  Or,

2) Rewrite the script to set appropriate environment variables at Bash startup, 
then remove all uname checks and instead test the environment variables.  This 
would be more efficient since the uname command is external to Bash whereis the 
environment test is internal. Or,

3) Switch to zsh.  (A little joke to lighten the mood.)

Home | Main Index | Thread Index | Old Index