Opened 8 years ago

Closed 6 years ago

#161 closed enhancement (fixed)

dash: Support BEGINLIBPATH and LIBPATHSTRICT

Reported by: dmik Owned by: dmik
Priority: major Milestone:
Component: dash Version:
Severity: medium Keywords:
Cc:

Description

Currently, dash completely lacks support for these pseudo environment variables so it's impossible to set them from a shell script (ash is capable of it). We need to fix it (this doesn't look too difficult).

Change History (4)

comment:1 by dmik, 6 years ago

Owner: set to dmik
Status: newassigned

comment:2 by dmik, 6 years ago

Resolution: fixed
Status: assignedclosed

This is done in r2289. Note that I mimic CMD.EXE behavior there in that it doesn't allow assigning BEGINLIBPATH and friends an arbitrary value. This is a limitation (feature?) of DosSetExtLIBPATH API, to be exact: it corrects the input string as needed and only assigns what it thinks is OK. I.e., doing this:

set BEGINLIBPATH=D:\Temp;BLAHBLAH
set LIBPATHSTRICT=True
echo %BEGINLIBPATH%
echo %LIBPATHSTRICT%

will output this:

D:\Temp;
T

I.e. wrong input will be simply discarded. CMD.EXE doesn't do it on its own, it just reads the real result with DosQueryExtLIBPATH after each assignment and updates its variable representation accordingly. So does dash.

Note that ash (from kLIBC) is not that smart; it keeps the user input even though it was refused by the Dos API which might give some unexpected side effects. The other cool thing dash does and ash doesn't is slash conversion: within dash, all slashes in BEGINLIBPATH and ENDLIBPATH will be converted to forward ones (good that Dos API eats them well too). And when calling external commands, they will be converted back to backward slashes (for DOS compatibility) — just like any other PATH-like variable (which is also a dash unique feature, see #104).

I will test the new dash locally for a while and then release a new RPM.

comment:3 by dmik, 6 years ago

Resolution: fixed
Status: closedreopened

I found one failing case that works in CMD.EXE. Consider you have bin/myapp.exe and bin/myapp.dll needed by that exe. Then this bin/myapp.cmd script will make the exe work well:

set BEGINLIBPATH=..\lib
myapp.exe

However, the respective shell scrip:

BEGINLIBPATH=../lib
myapp.exe

will not work.

If you change it to:

BEGINLIBPATH=..\\lib
myapp.exe

it will work too, but it's really not a good idea to force backward slashes in POXSIX shell, it's about to break a lot of code.

For some reason DosSetExtLIBPATH API accepts forward slashes in full paths but doesn't accept them in relative paths (while accepting relative paths themselves which is a bit of as surprise) — it simply discards such paths as bad input.

I guess that converting all forward slashes into backward ones before feeding them to DosSetExtLIBPATH will fix this problem.

comment:4 by dmik, 6 years ago

Resolution: fixed
Status: reopenedclosed

Fixed in r2290.

Note: See TracTickets for help on using tickets.