Proposal: Add getFullProgName

Thomas Schilling nominolo at googlemail.com
Wed Jun 13 02:59:50 CEST 2012


I don't think this is guaranteed to work.  See top answer here [1]
(which cites the standard).  Also, note that the man page for exec and
friends notes that the first argument *by convention* is the name of
the executable.

I'm not against exposing a function to return argv[0] (I thought
getProgName did that), but the documentation should make clear that it
is not guaranteed to work.

[1]: http://stackoverflow.com/questions/2050961/is-argv0-name-of-executable-an-accepted-standard-or-just-a-common-conventi

On 13 June 2012 00:57, Johan Tibell <johan.tibell at gmail.com> 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
>
> -- Johan
>
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://www.haskell.org/mailman/listinfo/libraries



-- 
Push the envelope. Watch it bend.



More information about the Libraries mailing list