Bug 151536 - Extract prependToEnvironmentVariableList
Summary: Extract prependToEnvironmentVariableList
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: Other
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: David Kilzer (:ddkilzer)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-11-21 19:17 PST by David Kilzer (:ddkilzer)
Modified: 2015-11-26 08:45 PST (History)
6 users (show)

See Also:


Attachments
Patch v1 (13.53 KB, patch)
2015-11-21 20:02 PST, David Kilzer (:ddkilzer)
dbates: review+
dbates: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description David Kilzer (:ddkilzer) 2015-11-21 19:17:40 PST
Extract prependToEnvironmentVariableList() subroutine in webkitdirs.pm.
Comment 1 David Kilzer (:ddkilzer) 2015-11-21 20:02:41 PST
Created attachment 266038 [details]
Patch v1
Comment 2 Alexey Proskuryakov 2015-11-21 21:14:48 PST
Comment on attachment 266038 [details]
Patch v1

View in context: https://bugs.webkit.org/attachment.cgi?id=266038&action=review

> Tools/ChangeLog:13
> +        (appendToEnvironmentVariableList): Simplify variable name and

How did you decide to change the logic of this function? I think that the new behavior is semantically wrong, at least for PATH.
Comment 3 David Kilzer (:ddkilzer) 2015-11-22 02:37:28 PST
(In reply to comment #2)
> Comment on attachment 266038 [details]
> Patch v1
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=266038&action=review
> 
> > Tools/ChangeLog:13
> > +        (appendToEnvironmentVariableList): Simplify variable name and
> 
> How did you decide to change the logic of this function? I think that the
> new behavior is semantically wrong, at least for PATH.

Because I wrote tests to check the behavior.  Please describe a test case that you think is wrong.
Comment 4 Daniel Bates 2015-11-22 12:16:36 PST
Comment on attachment 266038 [details]
Patch v1

View in context: https://bugs.webkit.org/attachment.cgi?id=266038&action=review

> Tools/Scripts/webkitdirs.pm:1387
> +        $ENV{$name} .= ":" if substr($ENV{$name}, -1) ne ":";

This is OK as-is. I suspect that this function (both the original and after your changes) does not work when invoked from a Perl program run directly in the Windows command prompt because Windows uses ';' for its PATH separator. We should consider making use of $Config::Config{path_sep} for the platform-specific PATH separator or consider naming this function appendToUnixEnvironmentVariableList(). This work can be done in a separate patch.

You can read more about $Config::Config{pah_sep} at <http://perldoc.perl.org/Config.html#p>.

> Tools/Scripts/webkitdirs.pm:1399
> +        my $joinCharacter = substr($ENV{$name}, 0, 1) eq ":" ? "" : ":";

Similiarly, we should use $Config::Config{path_sep} for the platform-specific PATH separator or consider naming this function prependToUnixEnvironmentVariableList().

> Tools/Scripts/webkitperl/webkitdirs_unittest/appendToEnvironmentVariableList.pl:74
> +    description => "Append to single path with colon",

Dyld(1) does not clarify whether DYLD_FRAMEWORK_PATH follows POSIX convention for the PATH environment variable. For the PATH environment variable, this expected result is incorrect per <http://pubs.opengroup.org/onlinepubs/000095399/basedefs/xbd_chap08.html#tag_08_03> because a trailing colon at the end of the list of prefixes is called the zero-length prefix, which represents the current working directory. If we choose to support this legacy behavior (you at least propose supporting the zero-length prefix at the beginning of the list of prefixes) then one way to achieve conformance is to unconditionally append a colon before appending the value (as we did in the original behavior of appendToEnvironmentVariableList()). Though this can yield a PATH that has one or more zero-length prefixes (e.g. "::").
Comment 5 Alexey Proskuryakov 2015-11-22 23:13:04 PST
Daniel explained this in detail, a trailing colon has a different meaning (thanks Daniel!). IIRC this was discussed when the code was originally written, did you blame the code and read discussion in the bug before assuming that it was wrong?
Comment 6 David Kilzer (:ddkilzer) 2015-11-26 08:43:51 PST
Committed r192774: <http://trac.webkit.org/changeset/192774>
Comment 7 David Kilzer (:ddkilzer) 2015-11-26 08:45:19 PST
(In reply to comment #5)
> Daniel explained this in detail, a trailing colon has a different meaning
> (thanks Daniel!). IIRC this was discussed when the code was originally
> written, did you blame the code and read discussion in the bug before
> assuming that it was wrong?

Nope, I didn't happen to blame it or read the discussion.  Thanks for info; I made the corrections before landing the patch (no logic change to appendToEnvironmentVariableList()).