Opened 10 years ago

Last modified 10 years ago

#47706 new enhancement

base: postflight.in: Missing check causes duplicate PATH entries when sourcing CONF_FILE

Reported by: anonymous@… Owned by: macports-tickets@…
Priority: Normal Milestone:
Component: base Version: 2.3.3
Keywords: Cc:
Port:

Description (last modified by larryv (Lawrence Velázquez))

When sourcing CONF_FILE (in this case ~/.profile) with source ~/.profile, my PATH variable expands indefinitely, since there is no check if BINPATH is already in PATH (trunk/base/portmgr/dmg/postflight.in#L243).

My ~/.profile looks like this:

# MacPorts Installer addition on 2015-01-17_at_00:00:40: adding an appropriate PATH variable for use with MacPorts.                                                                                                                                                                       
export PATH="/opt/local/bin:/opt/local/sbin:$PATH"
# Finished adapting your PATH environment variable for use with MacPorts.

The solution is to check in source:trunk/base/portmgr/dmg/postflight.in#L103 if BINPATH (Part of ${2}) is already in PATH (\$ + ${1}). If so, do not export it again.

I fixed it in my ~/.profile with this modification (bash):

# MacPorts Installer addition on 2015-01-17_at_00:00:40: adding an appropriate PATH variable for use with MacPorts.                                                                                                                                                                        
[[ ! "$PATH" =~ "/opt/local/bin:/opt/local/sbin" ]] && export PATH="/opt/local/bin:/opt/local/sbin:$PATH"
# Finished adapting your PATH environment variable for use with MacPorts.

Change History (2)

comment:1 Changed 10 years ago by larryv (Lawrence Velázquez)

Description: modified (diff)
Keywords: PATH postflight.in removed

comment:2 Changed 10 years ago by ryandesign (Ryan Carsten Schmidt)

That's not a bad idea. I might use separate lines for bin and sbin, in case the user has them in a different order for some reason.

Note: See TracTickets for help on using tickets.