Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
gargantext-ihaskell
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
gargantext-ihaskell
Commits
051cdde8
Commit
051cdde8
authored
May 18, 2014
by
Andrew Gibiansky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
:!cd now changes directory for user code
parent
943eb9fd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
26 deletions
+33
-26
Test.ipynb
notebooks/Test.ipynb
+19
-21
Evaluate.hs
src/IHaskell/Eval/Evaluate.hs
+14
-5
No files found.
notebooks/Test.ipynb
View file @
051cdde8
...
...
@@ -36,19 +36,8 @@
"cell_type": "code",
"collapsed": false,
"input": [
"getStringTarget :: String -> String\n",
"getStringTarget = go \"\" . reverse\n",
" where\n",
" go acc rest = case rest of\n",
" '\"':'\\\\':rem -> go ('\"':acc) rem\n",
" '\"':rem -> acc\n",
" ' ':'\\\\':rem -> go (' ':acc) rem\n",
" ' ':rem -> acc\n",
" x:rem -> go (x:acc) rem\n",
" [] -> acc\n",
"\n",
"\" ~/archive/\n",
":load \" ~/archive/"
"import System.Directory\n",
"getDirectoryContents \".\""
],
"language": "python",
"metadata": {
...
...
@@ -56,38 +45,47 @@
},
"outputs": [
{
"html": [
"<span class='err-msg'>Parse error (line 12, column 13): lexical error in string/character literal at end of input</span>"
],
"metadata": {},
"output_type": "display_data",
"text": [
"
Parse error (line 12, column 13): lexical error in string/character literal at end of input
"
"
[\".\",\"..\",\".hdevtools.sock\",\"blog\",\"experiments\",\"hackathon\",\"haskell-course-preludes\",\"haskell-style-guide\",\"ihaskell\",\"ihaskell-app\",\"linal\",\"notes\",\"slinky.nb\",\"tasha\"]
"
]
}
],
"prompt_number":
1
"prompt_number":
9
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"getStringTarget \"absdf\\\" he\\\\\\\"llo\""
":!cd code\n",
":!pwd\n",
"setCurrentDirectory \"code\""
],
"language": "python",
"metadata": {
"hidden": false
},
"outputs": [
{
"html": [
"<span class='err-msg'>No such directory: 'code'</span>"
],
"metadata": {},
"output_type": "display_data",
"text": [
"No such directory: 'code'"
]
},
{
"metadata": {},
"output_type": "display_data",
"text": [
"
\"he\\\"llo\"
"
"
/Users/silver/code
"
]
}
],
"prompt_number":
13
"prompt_number":
8
},
{
"cell_type": "code",
...
...
src/IHaskell/Eval/Evaluate.hs
View file @
051cdde8
...
...
@@ -106,6 +106,7 @@ globalImports :: [String]
globalImports
=
[
"import IHaskell.Display()"
,
"import qualified Prelude as IHaskellPrelude"
,
"import qualified System.Directory as IHaskellDirectory"
,
"import qualified IHaskell.Display"
,
"import qualified IHaskell.IPython.Stdin"
,
"import qualified System.Posix.IO as IHaskellIO"
...
...
@@ -498,24 +499,32 @@ evalCommand _ (Directive LoadFile name) state = wrapExecution state $ do
modName
<-
intercalate
"."
<$>
getModuleName
contents
doLoadModule
filename
modName
evalCommand
publish
(
Directive
ShellCmd
(
'!'
:
cmd
))
state
=
wrapExecution
state
$
liftIO
$
evalCommand
publish
(
Directive
ShellCmd
(
'!'
:
cmd
))
state
=
wrapExecution
state
$
case
words
cmd
of
"cd"
:
dirs
->
do
-- Get home so we can replace '~` with it.
homeEither
<-
try
$
getEnv
"HOME"
::
IO
(
Either
SomeException
String
)
homeEither
<-
liftIO
(
try
$
getEnv
"HOME"
::
IO
(
Either
SomeException
String
)
)
let
home
=
case
homeEither
of
Left
_
->
"~"
Right
val
->
val
let
directory
=
replace
"~"
home
$
unwords
dirs
exists
<-
doesDirectoryExist
directory
exists
<-
liftIO
$
doesDirectoryExist
directory
if
exists
then
do
setCurrentDirectory
directory
-- Set the directory in IHaskell native code, for future shell
-- commands. This doesn't set it for user code, though.
liftIO
$
setCurrentDirectory
directory
-- Set the directory for user code.
let
cmd
=
printf
"IHaskellDirectory.setCurrentDirectory
\"
%s
\"
"
$
replace
" "
"
\\
"
$
replace
"
\"
"
"
\\\"
"
directory
runStmt
cmd
RunToCompletion
return
mempty
else
return
$
displayError
$
printf
"No such directory: '%s'"
directory
cmd
->
do
cmd
->
liftIO
$
do
(
readEnd
,
writeEnd
)
<-
createPipe
handle
<-
fdToHandle
writeEnd
pipe
<-
fdToHandle
readEnd
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment