Opened 22 months ago

Closed 22 months ago

Last modified 22 months ago

#7029 closed feature request (fixed)

Add System.Environment.getExecutablePath

Reported by: tibbe Owned by:
Priority: normal Milestone: 7.6.1
Component: libraries/base Version: 7.4.2
Keywords: Cc: johan.tibell@…
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

As agreed after the corresponding libraries@ discussion (http://thread.gmane.org/gmane.comp.lang.haskell.libraries/17368) we should add System.Environment.getExecutablePath. Attached is an implementation for OS X, Linux, and Windows, with a fallback to argv[0] on other platforms.

The Windows implementation was written without access to a Windows machine, so someone will need to test it on Windows to make sure it compiles/works.

Attachments (1)

0001-Add-System.Environment.getExecutablePath.patch (7.5 KB) - added by tibbe 22 months ago.

Download all attachments as: .zip

Change History (10)

comment:1 Changed 22 months ago by tibbe

  • Cc johan.tibell@… added
  • Status changed from new to patch

comment:2 Changed 22 months ago by tibbe

I've now validate that it works on OS X and Linux. The fallback also works. Could someone please validate on Windows and fix any errors?

comment:3 follow-up: Changed 22 months ago by pcapriotti

  • Difficulty set to Unknown
  • Milestone set to 7.6.1

Would it make sense to fall back to argv[0] on Linux when /proc is not mounted?

comment:4 in reply to: ↑ 3 Changed 22 months ago by tibbe

Replying to pcapriotti:

Would it make sense to fall back to argv[0] on Linux when /proc is not mounted?

Sure. Do you know a reliable way to check for that condition?

comment:5 follow-up: Changed 22 months ago by pcapriotti

Ah, I was just thinking to fall back to argv[0] when readlink returns ENOENT, or even possibly when readlink fails for any reason.

comment:6 Changed 22 months ago by tibbe

FYI, Linux and OS X validates for me.

comment:7 in reply to: ↑ 5 Changed 22 months ago by tibbe

Replying to pcapriotti:

Ah, I was just thinking to fall back to argv[0] when readlink returns ENOENT, or even possibly when readlink fails for any reason.

As discussed offline. Lets get this in and then start adding fallbacks for different more uncommon cases (Linux without /proc, BSDs, etc.)

comment:8 Changed 22 months ago by pcapriotti

  • Resolution set to fixed
  • Status changed from patch to closed

Thanks. Tested on Windows and merged:

commit ca72c8e005ae78939645f27328bd81a91943453d
Author: Paolo Capriotti <p.capriotti@gmail.com>
Date:   Wed Jun 27 18:56:32 2012 +0100

    Add System.Environment.getExecutablePath (#7029)
    
    Patch by Johan Tibell <johan.tibell@gmail.com>

comment:9 Changed 22 months ago by simonmar

Nice job, it's good to have this in.

Note: See TracTickets for help on using tickets.