Global load() doesn't subsitute environment variables

UNCONFIRMED
Unassigned

Status

Rhino
Core
UNCONFIRMED
10 years ago
4 years ago

People

(Reporter: Josh Allen, Unassigned)

Tracking

Details

Attachments

(4 attachments)

(Reporter)

Description

10 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.7) Gecko/20070914 Firefox/2.0.0.7
Build Identifier: 1.6R7

org.mozilla.javascript.tools.shell.Global#load doesn't substitute environment variables for path names. So for example 

Reproducible: Always

Steps to Reproduce:
1. Create a javascript file
2. Add a first line load("$JSDIR/core-util.js")
3. Run javascript
Actual Results:  
Doesn't exapand $JSDIR

Expected Results:  
Expands $JSDIR

I have a patch ready, I'll submit it once this bugs been submitted.
(Reporter)

Comment 1

10 years ago
Created attachment 284848 [details] [diff] [review]
Fix, part 1, patch to org.mozilla.javascript.tools.shell.Global

Note that the patch to bug https://bugzilla.mozilla.org/show_bug.cgi?id=368323 should also be applied because this solution uses runProcess.
Attachment #284848 - Flags: review?
(Reporter)

Comment 2

10 years ago
Created attachment 284849 [details] [diff] [review]
Fix, part 2, patch to org\mozilla\javascript\tools\resources\Message.properties
(Reporter)

Comment 3

10 years ago
Created attachment 284850 [details]
Fix, part 3, new file, org\mozilla\javascript\tools\resources\Message_fr.properties

French translation to addition to Message.properties
(Reporter)

Comment 4

10 years ago
Created attachment 284851 [details]
Fix, part 4, new file, org.mozilla.javascript.tools.shell.GlobalExpandVarsTest

Unit tests for org.mozilla.javascript.tools.shell.Global#expandVars (JUnit 4)

Environments this was tested on:
CentOS release 4.5 (Final)
Microsoft Windows XP [Version 5.1.2600]

To be sure, it should be tested on the Mac too.

Last part of fix.

Comment 5

8 years ago
((I know it's an old bug, but it's not RESOLVED))

I don't see a reason for load to expand env variables.
This is JavaScript, not shell scripting, if you can't use env vars the issue is a function for getting env vars is needed inside the shell so that you can grab the value of an env var and + it onto a path. load() is supposed to take a legal path to a file, NOT expected to follow shell substitution rules which rather than being helpful could result in gotchas where paths are substituted where they shouldn't be.

Recommend WONTFIX. You can already access env variables through LiveConnect.
Attachment #284848 - Flags: review?
You need to log in before you can comment on or make changes to this bug.