Opened 13 years ago

Closed 12 years ago

#30664 closed enhancement (wontfix)

bash-completion: document to source $prefix/etc/profile.d/

Reported by: blair (Blair Zajac) Owned by: raimue (Rainer Müller)
Priority: Normal Milestone:
Component: ports Version: 2.0.1
Keywords: Cc: hxliang1982@…, jendave@…
Port: bash-completion maven

Description

Hello,

The maven* ports are going to install files into $prefix/etc/profile.d. It would be nice if bash-completion port changed its note to use this code instead in ~/bash_profile:

if test -d $prefix/etc/profile.d; then
  for i in $prefix/etc/profile.d/*.sh; do
    if test -r $i; then
      . $i
    fi
  done
  unset i
fi

Change History (8)

comment:1 Changed 13 years ago by mf2k (Frank Schima)

Owner: changed from macports-tickets@… to raimue@…

comment:2 Changed 13 years ago by blair (Blair Zajac)

Resolution: fixed
Status: newclosed

Maintainer timeout so I applied the change in r82253.

comment:3 Changed 13 years ago by raimue (Rainer Müller)

Resolution: fixed
Status: closedreopened

Sorry, I wasn't able to respond in time as I am on travel.

I don't see how this is related to bash-completion in any way? Please add a note to maven instead if it needs to source any stuff to work. Any port needs to install it's bash-completion related files into ${prefix}/etc/bash_completion.d. It is a failure in these ports, not in bash-completion.

If the directory etc/profile.d contains unrelated files, it will do more than just enabling bash-completion. This is not the behavior users would expect and therefore this is dangerous.

comment:4 Changed 13 years ago by blair (Blair Zajac)

There's a couple of issues you're raising, the issue about ports adding completions into $prefix/etc/bash_completion.d isn't the issue here.

Another issue is that other ports are doing to start dropping things into $prefix/etc/profile.d and the normal way to source them is to source them all instead of sourcing them individually. This is how Linux works and where the bash code was copied from.

To the dangerous point, I don't get that. How is this dangerous if the port expects some environment set up to run? Linux works this way, if you install a package it'll drop files in /etc/profile.d that are automatically sourced. There's no suggestion that's dangerous???

The last point is that right now the bash-completion port says to source $prefix/etc/bash_completion, but if you also source everything in $prefix/etc/profile.d, then because bash-completion drops a bash_completion.sh in there also, there will be double sourcing, which I would rather not see.

comment:5 Changed 13 years ago by raimue (Rainer Müller)

If you source everything in ${prefix}/etc/profile.d it's your responsibility to ensure that things will not be sourced multiple times. MacPorts does not use ${prefix}/etc/profile.d, instead ports usually create wrappers which set the required environment variables. For an example, see the wine port. If we always want to source ${prefix}/etc/profile.d, we would need different installation instructions.

If maven needs some special environment, it is a bug in maven. Add a note to maven that it needs special environment.

The note in the bash-completion port should tell people how to enable bash-completion. It should not tell how to source all things which have been dropped into ${prefix}/etc/profile.d. Files there might do stuff which is unrelated to bash-completion. Let's say it's not dangerous, but unexpected behavior if the instructions for bash-completion influence other tools.

comment:6 Changed 13 years ago by raimue (Rainer Müller)

Cc: jendave@… added
Port: maven added

Reverted the change in r82404. Leaving the issue open, probably this needs to be adressed in maven.

comment:7 Changed 13 years ago by blair (Blair Zajac)

Yes, we need to watch out that you don't source things in ${prefix}/etc/profile.d twice. My concern is that with the instructions to source /$prefix/etc/bash_completion and if/when we have people source in ${prefix}/etc/profile.d will cause a double source of bash-completion.

comment:8 Changed 12 years ago by raimue (Rainer Müller)

Resolution: wontfix
Status: reopenedclosed

Sourcing bash-completion multiple times is not bad as it detects that it has been sourced already. I don't think we need to do something about this in bash-completion.

Note: See TracTickets for help on using tickets.