Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 21257 - app-shells/bash-completion not installed correctly
Summary: app-shells/bash-completion not installed correctly
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: x86 Linux
: High normal
Assignee: Christian Birchinger (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-05-19 11:40 UTC by Peter Simons
Modified: 2003-05-24 09:51 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Simons 2003-05-19 11:40:50 UTC
Please pardon me if I mixed this up myself, but I think that the bash-completion
package does not install itself correctly. It appears to expect the contents of
/etc/profile.d/ to be sourced at login, which -- at least my system's --
/etc/profile -- does not do! So effectively, bash-completion won't be activated!
I had to add the appropriate commands in /etc/profile manually.

Another thing is that the /etc/profile.d/bash_completion script does not check
wheth bash has been run as /bin/sh, in which case it will be POSIX compatible
and does not support functions, causing the script to fail with syntax errors!

To fix this, I changed the shell code to the following:


 | # Configure bash completion.
 | bash=${BASH_VERSION%.*}; bmajor=${bash%.*}; bminor=${bash#*.}
 | if [ "$PS1" ] && [ $bmajor -eq 2 ] && [ $bminor '>' 04 ] &&     \
 |    [ -f /etc/bash_completion ] &&                               \
 |    [ "$POSIXLY_CORRECT" != "y" ]; then
 |     . /etc/bash_completion
 | fi
 | unset bash bmajor bminor

The interesting part is the check whether $POSIXLY_CORRECT is not equal to "y".
Comment 1 Christian Birchinger (RETIRED) gentoo-dev 2003-05-19 18:37:09 UTC
/etc/profile.d/bash_completion is not sourced automaticaly. You need to add 
this manualy into /etc/profile. The ebuild informs about this:

einfo "Add the following line to your ~/.bashrc to"
einfo "activate completion support in your bash:"
einfo "[ -f /etc/profile.d/bash-completion ] && source /etc/profile.d/bash-completion"

Currently i don't think about chaning this way.


/bin/sh already rejects variable handling like " bash=${BASH_VERSION%.*} ".
Anyway would it even set variables like BASH_VERSION? sh don' have this.
Comment 2 Peter Simons 2003-05-19 18:45:44 UTC
Well, fair enough. I just wonder whether /etc/profile.d is a good place to install it then, because the path _suggests_ it would be executed automatically! Perhaps /etc/skel would be better? Anyway, it's probably not that important ... No big deal.

As for /bin/sh: On my system, the /bin/sh _is_ a bash, but it's a bash that's operating in POSIX-compliant mode. A true Bourne shell would probably choke at the shell code already (one more reason to change the code!), but the POSIXLY_CORRECT bash works fine -- except when it comes to function declaration. Here it will abort with an error.
Comment 3 Christian Birchinger (RETIRED) gentoo-dev 2003-05-19 18:53:12 UTC
I just started the bash with "bash --posix -l" and it sets POSIXLY_CORRECT=y
and then i sourced /etc/bash_completion.

It works fine with the generic bash_completion release. Ok, set doesn't list the
functions but completion works well.

All errors i get are from the "gentoo" specific completion commands:
bash: `_rc-update': not a valid identifier
bash: `_gcc-config': not a valid identifier
bash: `_java-config': not a valid identifier
bash: `_opengl-update': not a valid identifier

Thos are only from /etc/bash_completion.d/gentoo.

I think that needs to be fixed rather than disabling it in complettly. Problem
is i'm not the one who writes that gentoospecific completion so i have to forward
it to the author and hope he fixes it.
Comment 4 Christian Birchinger (RETIRED) gentoo-dev 2003-05-19 18:59:30 UTC
I don't like skel because it is only for $HOME and i don't want it sourced in my
home. I want it global on my box (matter of taste).

Personaly i think not automaticaly executing /etc/profile.d is a design flaw
but this issue is at the wrong place. It's a generic profile issue.

Personaly i even use this in /etc/profile

# Append any additional sh scripts found in /etc/profile.d/:
for file in /etc/profile.d/* ; do
  if [ -x $file ]; then
    source $file
  fi
done

(I activate scripts with +x and deactivate them with -x ofcourse the if-check
can be removed and everything will be sourced)

But as i said, automaticaly sourcing /etc/profile.d is not under my control
anymore.
Comment 5 Christian Birchinger (RETIRED) gentoo-dev 2003-05-24 09:51:08 UTC
Posix wont allow dashes in function names. That's why all gentoo specific functions failed. The author of the gentoo specific function sent an update with
works. Starting "bash --posix -l" then ". /etc/bash-completion" works without
error.

The automated sourcing of /etc/profile.d is not under my control and does not
belong to to a bash-completion bugreport. I could be also seen as a feature
request. If really needed i suggest open a feature request in a new report.