path normalisation in "base"

René J.V. Bertin rjvbertin at gmail.com
Tue Oct 11 07:04:21 PDT 2016


On Tuesday October 11 2016 09:21:09 Daniel J. Luke wrote:

>one way to handle it could be:
>+        # don't normalize absolute paths

See my previous message about why normalisation might be used here; completing a relative path is clearly another reason.

I wonder a bit why `port provides` supports relative paths; is it used in scripts (or even Portfiles)?

I could imagine this:

{{{
proc macports::normalize { filename } {
    set nprefix [file dirname [file normalize "${macports::prefix}/foo"]]
    return [string map {${nprefix} ${macports::prefix}} [file normalize $filename]]
}
}}}

and then action_provides can use macports::normalize instead of [file normalize].

I'll presume that [string map] will check if ${nprefix} and ${macports::prefix} are equal before doing a replacement mapping.

R.


More information about the macports-dev mailing list