Proposal: Add getFullProgName

wren ng thornton wren at freegeek.org
Thu Jun 14 03:31:20 CEST 2012


On 6/12/12 7:57 PM, Johan Tibell wrote:
> Hi,
>
> getProgName is only useful in case you want to print the program name
> to the screen. You cannot actually use it to do anything interesting
> programmatically (like execv:ing the program.) I suggest we add
> getFullProgName which does the sensible thing of returning argv[0].
> Here's an implementation:
>
> getFullProgName :: IO String
> getFullProgName =
>      alloca $ \ p_argc ->
>      alloca $ \ p_argv ->  do
>          getFullProgArgv p_argc p_argv
>          peek p_argv>>= peek>>= peekCString
>
> foreign import ccall unsafe "getFullProgArgv"
>      getFullProgArgv :: Ptr CInt ->  Ptr (Ptr CString) ->  IO ()
>
> Discussion deadline: 2 weeks


FWIW, cf: http://hackage.haskell.org/package/system-argv0

-- 
Live well,
~wren



More information about the Libraries mailing list