[GHC] #3200: System.Environment.withProgName strips everything before the last slash

GHC trac at galois.com
Tue Apr 28 16:50:25 EDT 2009


#3200: System.Environment.withProgName strips everything before the last slash
-----------------------------+----------------------------------------------
Reporter:  guest             |          Owner:                  
    Type:  bug               |         Status:  new             
Priority:  normal            |      Component:  libraries/base  
 Version:  6.10.2            |       Severity:  normal          
Keywords:                    |       Testcase:                  
      Os:  Unknown/Multiple  |   Architecture:  Unknown/Multiple
-----------------------------+----------------------------------------------
 The documentation for `withProgName` says:

   withProgName name act - while executing action act, have getProgName
 return name.

 However:
 {{{
 % ghc -e 'System.Environment.withProgName "Hello / World///."
 System.Environment.getProgName'
 "."
 }}}

 I discovered this while trying to work around bug #3199 like this:
 {{{
 main = do
     exe <- readSymbolicLink "/proc/self/exe"
     withProgName exe main'
 ...
 }}}

 So... I need to re-exec my program. Fortunately, there is `argv[0]`
 containing exactly the information I need. Unfortunately, Haskell doesn't
 let me access it. Fortunately, Linux provides the full path to my program
 in a special file and Haskell lets me "fix" the program name at startup.
 Unfortunately, this functionality is broken: `withProgName` only takes the
 part after the last slash. Back to square one. :-(

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/3200>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the Glasgow-haskell-bugs mailing list