-
Notifications
You must be signed in to change notification settings - Fork 841
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement #3264 adding --cwd to exec #3497
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -105,7 +105,7 @@ import qualified Stack.Upload as Upload | |
import qualified System.Directory as D | ||
import System.Environment (getProgName, getArgs, withArgs) | ||
import System.Exit | ||
import System.FilePath (pathSeparator) | ||
import System.FilePath (isRelative, isValid, pathSeparator) | ||
import System.IO (hIsTerminalDevice, stderr, stdin, stdout, hSetBuffering, BufferMode(..), hPutStrLn, hGetEncoding, hSetEncoding) | ||
|
||
-- | Change the character encoding of the given Handle to transliterate | ||
|
@@ -767,7 +767,8 @@ execCmd ExecOpts {..} go@GlobalOpts{..} = | |
(ExecRunGhc, args) -> | ||
getGhcCmd "run" menv eoPackages args | ||
munlockFile lk -- Unlock before transferring control away. | ||
exec menv cmd args | ||
|
||
runWithPath eoCwd $ exec menv cmd args | ||
where | ||
-- return the package-id of the first package in GHC_PACKAGE_PATH | ||
getPkgId menv wc name = do | ||
|
@@ -788,6 +789,20 @@ execCmd ExecOpts {..} go@GlobalOpts{..} = | |
pkgopts <- getPkgOpts menv wc pkgs | ||
return (prefix ++ compilerExeName wc, pkgopts ++ args) | ||
|
||
runWithPath path callback = case path of | ||
Nothing -> callback | ||
Just p | not (isValid p) -> callback | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, it seems like this would silently ignore |
||
Just p -> | ||
if isRelative p | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it'd be cleaner to just use |
||
then parseRelDir p >>= runInDirectory | ||
else parseAbsDir p >>= runInDirectory | ||
where | ||
runInDirectory :: (Path t Dir) -> RIO EnvConfig () | ||
runInDirectory directory = | ||
withUnliftIO $ \unlift -> | ||
withCurrentDir directory $ unliftIO unlift callback | ||
|
||
|
||
-- | Evaluate some haskell code inline. | ||
evalCmd :: EvalOpts -> GlobalOpts -> IO () | ||
evalCmd EvalOpts {..} go@GlobalOpts {..} = execCmd execOpts go | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also add
For better help output and path completion for this option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done :)