diff --git a/intTests/test_pwd/README.md b/intTests/test_pwd/README.md new file mode 100644 index 0000000000..ed1a57fc58 --- /dev/null +++ b/intTests/test_pwd/README.md @@ -0,0 +1,3 @@ +Test the REPL's `:pwd` command. This test will pass if the REPL output of this +command includes, in any position, the current working directory as rendered by +`bash`'s `pwd`. \ No newline at end of file diff --git a/intTests/test_pwd/test.sh b/intTests/test_pwd/test.sh new file mode 100644 index 0000000000..a336b468ff --- /dev/null +++ b/intTests/test_pwd/test.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +set -e + +HERE=`pwd` +RES=`echo ':pwd' | $SAW --interactive --no-color` +[[ "$RES" =~ .*"$HERE".* ]] \ No newline at end of file diff --git a/saw/SAWScript/REPL/Command.hs b/saw/SAWScript/REPL/Command.hs index df278eb073..2c6c6413c4 100644 --- a/saw/SAWScript/REPL/Command.hs +++ b/saw/SAWScript/REPL/Command.hs @@ -43,7 +43,7 @@ import Data.Char (isSpace,isPunctuation,isSymbol) import Data.Function (on) import Data.List (intercalate) import System.FilePath((), isPathSeparator) -import System.Directory(getHomeDirectory,setCurrentDirectory,doesDirectoryExist) +import System.Directory(getHomeDirectory,getCurrentDirectory,setCurrentDirectory,doesDirectoryExist) import qualified Data.Map as Map -- SAWScript imports @@ -124,6 +124,8 @@ commandList = "exit the REPL" , CommandDescr ":cd" (FilenameArg cdCmd) "set the current working directory" + , CommandDescr ":pwd" (NoArg pwdCmd) + "display the current working directory" ] genHelp :: [CommandDescr] -> [String] @@ -194,6 +196,9 @@ cdCmd f | null f = io $ putStrLn $ "[error] :cd requires a path argument" then io $ setCurrentDirectory f else raise $ DirectoryNotFound f +pwdCmd :: REPL () +pwdCmd = io $ getCurrentDirectory >>= putStrLn + -- SAWScript commands ---------------------------------------------------------- {- Evaluation is fairly straightforward; however, there are a few important