Hi
I was running into a similar problem while working on GHC not long ago -
short version is that it's not even possible to find out the executable
path portably from C [1]. Using argv[0] just gave me the path of the GHC
wrapper script, for example - as it uses exec without -a.
The whole thing
May I ask what the problem is you're trying to solve?
If you want to access datafiles in an installed program then Cabal can
help you with that. See
http://www.haskell.org/cabal/users-guide/#accessing-data-files-from-package-code
If you want to do more complicated things, maybe take a look at
On Thu, Dec 15, 2011 at 09:48, Peter Wortmann sc...@leeds.ac.uk wrote:
path portably from C [1]. Using argv[0] just gave me the path of the GHC
wrapper script, for example - as it uses exec without -a.
Note that exec -a is a bash-ism and not portable to POSIX shells (ash on
*BSD, dash on
On 16/12/2011, at 11:55 AM, Brandon Allbery wrote:
Note that exec -a is a bash-ism and not portable to POSIX shells
Recent versions of ksh also support this, so it's not just bash.
But there are certainly a lot of POSIX shells that don't, including
the version of ksh on my main machine.
In addition to argv[0]
http://hackage.haskell.org/packages/archive/system-argv0/0.1/doc/html/System-Argv0.html
There is also this package:
http://hackage.haskell.org/packages/archive/FindBin/0.0.5/doc/html/System-Environment-FindBin.html
System-Argv0 has special cases for windows- FindBin may
This is how I finally solved this problem for POSIX complaint system:
--
-- TestRun
--
module Main where
import System.Cmd (rawSystem)
import System.Directory (getCurrentDirectory)
import System.Environment.Executable (ScriptPath(..), getScriptPath)
import System.FilePath.Posix (splitFileName)
Balazs, thanks for your comments!
The first comment works just fine.
With / operator I get this:
Main System.Environment.Executable System.FilePath /abc / /
/
Instead of getting /abc/ I get /. What am I doing wrong?
On Mon, Dec 5, 2011 at 6:03 PM, Balazs Komuves bkomu...@gmail.com wrote:
Two
Hi.
On 5 December 2011 14:53, dokondr doko...@gmail.com wrote:
Main System.Environment.Executable System.FilePath /abc / /
/
Instead of getting /abc/ I get /. What am I doing wrong?
It thinks the second path is an absolute path.
Combine two paths, if the second path isAbsolute, then it
On Monday 05 December 2011, 15:53:35, dokondr wrote:
Balazs, thanks for your comments!
The first comment works just fine.
With / operator I get this:
Main System.Environment.Executable System.FilePath /abc / /
/
Instead of getting /abc/ I get /. What am I doing wrong?
The second path is
The operator / is an alias for `combine`, which the documentation says:
Combine two paths, if the second path isAbsolute, then it returns the second.
In this case, / is absolute, so it is returned.
If you wish to add a trailing path separator, use `addTrailingPathSeparator`.
Erik
On Mon,
Thanks,
'addTrailingPathSeparator' works just fine !
On Mon, Dec 5, 2011 at 7:52 PM, Erik Hesselink hessel...@gmail.com wrote:
The operator / is an alias for `combine`, which the documentation says:
Combine two paths, if the second path isAbsolute, then it returns the
second.
In this
Quoth wren ng thornton w...@freegeek.org,
There was a discussion about this recently over on libraries@, IIRC. The
short answer is that, at present, there is no function to give you $0.
We'd like to add such a function, but it's not been done yet.
Part of the problem is that, as Alexey
dokondr On the contrary, standard shell variable $0 - contains a full
dokondr path to the program location in the directory structure, no
dokondr matter from what directory the program was called.
I don't think the comparison makes sense, as shell script invocation and
executable run are very
On 4/12/2011, at 7:32 PM, wren ng thornton wrote:
Part of the problem is that, as Alexey says, the first element of argv is
just whatever is passed to exec, which is not guaranteed to be a complete
path, a canonical path, or any other specific thing we'd desire. It's not at
all
It's not a poor practice at all. Example: gcc, which uses the executable's
path as the base directory from which other files are located. MacOS also
does something similar.
-Original message-
From: Paul R paul.r...@gmail.com
To: dokondr doko...@gmail.com
Cc: Simon Hengel
That's true even for regular fork/exec.
-Original message-
From: Richard O'Keefe o...@cs.otago.ac.nz
To: wren ng thornton w...@freegeek.org
Cc: haskell-cafe haskell-cafe@haskell.org
Sent: Sun, Dec 4, 2011 15:54:15 PST
Subject: Re: [Haskell-cafe] How to get a file path to the program
On 12/1/11 11:12 AM, dokondr wrote:
Hi,
When my program starts it needs to know a complete path to the directory
from which it was invoked.
In terms of standard shell (sh) I need the Haskell function that will do
equivalent to:
#!/bin/sh
path=$(dirname $0)
That's not the path to the directory
On 12/1/11 2:26 PM, dokondr wrote:
How to find this path using GHC libraries?
There was a discussion about this recently over on libraries@, IIRC. The
short answer is that, at present, there is no function to give you $0.
We'd like to add such a function, but it's not been done yet.
Part
Hi,
When my program starts it needs to know a complete path to the directory
from which it was invoked.
In terms of standard shell (sh) I need the Haskell function that will do
equivalent to:
#!/bin/sh
path=$(dirname $0)
How to get this path in Haskell?
getProgName :: IO String
defined
How to get this path in Haskell?
Maybe FindBin or executable-path work.
Cheers,
Simon
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
On Thu, Dec 1, 2011 at 2:12 PM, dokondr doko...@gmail.com wrote:
Hi,
When my program starts it needs to know a complete path to the directory
from which it was invoked.
In terms of standard shell (sh) I need the Haskell function that will do
equivalent to:
#!/bin/sh
path=$(dirname $0)
How to get this path in Haskell?
If I understand you correctly, you want
takeDirectory `fmap` getProgName
I think getProgName does not give you the full path, but only the
program name.
Cheers,
Simon
___
Haskell-Cafe mailing list
On Thu, Dec 1, 2011 at 3:41 PM, Simon Hengel simon.hen...@wiktory.org wrote:
How to get this path in Haskell?
If I understand you correctly, you want
takeDirectory `fmap` getProgName
I think getProgName does not give you the full path, but only the
program name.
Neither does $0, does
On Thu, Dec 01, 2011 at 03:53:37PM -0200, Felipe Almeida Lessa wrote:
On Thu, Dec 1, 2011 at 3:41 PM, Simon Hengel simon.hen...@wiktory.org wrote:
How to get this path in Haskell?
If I understand you correctly, you want
takeDirectory `fmap` getProgName
I think getProgName does
On Thu, Dec 01, 2011 at 07:02:09PM +0100, Simon Hengel wrote:
On Thu, Dec 01, 2011 at 03:53:37PM -0200, Felipe Almeida Lessa wrote:
On Thu, Dec 1, 2011 at 3:41 PM, Simon Hengel simon.hen...@wiktory.org
wrote:
How to get this path in Haskell?
If I understand you correctly, you want
System.Directory.getCurrentDirectory does not solve the problem.
System.Directory.getCurrentDirectory returns the directory *from which* the
program was called, also called working directory.
The directory *from which* the program was called is not the same that the
directory *where the program
To be precise, $0 always contains the path to the program called. You are
right, this path will change depending on location from which the program
was called. So $0 is OK for my case, while current directory is unrelated.
Try this:
#!/bin/sh
echo Arg 0: $0
echo All Parameters: [$@]
Again,
On Thu, Dec 1, 2011 at 14:26, dokondr doko...@gmail.com wrote:
On the contrary, standard shell variable $0 - contains a full path to the
program location in the directory structure, no matter from what directory
the program was called
If the shell found it by $PATH search, $0 will be simply
dokondr doko...@gmail.com writes:
Hi,
When my program starts it needs to know a complete path to the directory from
which it was invoked.
In terms of standard shell (sh) I need the Haskell function that will do
equivalent to:
#!/bin/sh
path=$(dirname $0)
How to get this path in Haskell?
On 01.12.2011 23:47, dokondr wrote:
To be precise, $0 always contains the path to the program called. You
are right, this path will change depending on location from which the
program was called. So $0 is OK for my case, while current directory is
unrelated.
Actually it contains whatever was
Anton Nikishaev anton@gmail.com writes:
dokondr doko...@gmail.com writes:
Hi, When my program starts it needs to know a complete path to the
directory from which it was invoked. In terms of standard shell (sh)
I need the Haskell function that will do equivalent to:
#!/bin/sh
Balazs, thanks!
It's great that these packages exist!
On Thu, Dec 1, 2011 at 11:17 PM, Balazs Komuves bkomu...@gmail.com wrote:
Hello,
I'm not subscribed to haskell cafe, but I browse the archives sometimes.
As Simon Hengel wrote there, there are two packages on Hackage
trying to solve
32 matches
Mail list logo