Balazs, thanks for your comments!<br>The first comment works just fine.<br>With </> operator I get this:<br><br>Main System.Environment.Executable System.FilePath> "/abc" </> "/"<br>"/"<br>
<br>Instead of getting "/abc/" I get "/". What am I doing wrong?<br><br><div class="gmail_quote">On Mon, Dec 5, 2011 at 6:03 PM, Balazs Komuves <span dir="ltr"><<a href="mailto:bkomuves@gmail.com">bkomuves@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><br>Two small comments:<br><br>1) This should work on Windows too, if you just leave out the word "Posix" from the source:<br>
import System.FilePath (splitFileName)<br><br>2) In general when dealing with paths, use the </> operator (from System.FilePath)<br>
instead of ++ "/" ++<br><font color="#888888"><br>Balazs</font><div><div></div><div class="h5"><br><br><div class="gmail_quote">On Mon, Dec 5, 2011 at 1:44 PM, dokondr <span dir="ltr"><<a href="mailto:dokondr@gmail.com" target="_blank">dokondr@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
This is how I finally solved this problem for POSIX complaint system:<br><br>--<br>-- TestRun<br>--<br>module Main where<br>import System.Cmd (rawSystem)<br>import System.Directory (getCurrentDirectory)<br>import System.Environment.Executable (ScriptPath(..), getScriptPath)<br>
import System.FilePath.Posix (splitFileName)<br> <br> main = do <br> <br> path <- getMyPath<br> putStrLn $ "myPath = " ++ path<br> let cmdLine = path ++ "args.sh"<br> rawSystem cmdLine ["iphone", "test-twitts.txt"]<br>
<br>{--<br>data ScriptPath Source<br><br>Constructors:<br>Executable FilePath it was (probably) a proper compiled executable<br>RunGHC FilePath it was a script run by runghc/runhaskell<br>Interactive we are in GHCi <br>
--}<br><br>getMyPath = do<br> curDir <- getCurrentDirectory -- from System.Directory<br> scriptPath <- getScriptPath -- from System.Environment.Executable<br> let path = getMyPath' scriptPath curDir<br> return path<br>
<br>getMyPath' (Executable path) _ = fst (splitFileName path)<br>getMyPath' (RunGHC path) _ = fst (splitFileName path) <br>getMyPath' Interactive curDir = curDir++"/"<br><font color="#888888"><br>
</font><br>
</blockquote></div></div></div></blockquote></div>