missing quotation marks
bigwasp opened this issue · comments
Just tried nim-2.0.0 on Linux Mint 21.2 (Ubuntu 22.04 based)
import shell
shell:
one:
mkdir foo
pushd foo
echo "Hallo\nWorld" > test.txt
pipe:
cat test.txt
grep H
popd
rm foo/test.txt
rmdir foo
It seems that the quotation marks got lost.
Have i done something wrong?
Just compiled with nim c {file,nim}
Throws following:
ShellCmd: mkdir foo && pushd foo && echo Hallo
World > test.txt && cat test.txt | grep H && popd && rm foo/test.txt && rmdir foo
shell> /bin/sh: 1: pushd: not found
shell> /bin/sh: 2: World: not found
Error when executing: mkdir foo && pushd foo && echo Hallo
World > test.txt && cat test.txt | grep H && popd && rm foo/test.txt && rmdir foo
err>
Thanks for the report!
Hmm, I think it's a mix of two things:
- I must have written this example before we switched to
startProcess
. UsingstartProcess
we're not running in a normal terminal (so usingbash
for example), but rather with/bin/sh
.pushd
andpopd
are specificbash
(and other posix extending terminal emulator) features. So that's why it sayspushd: not found
. That's a regression in some sense, of course. Need to think about this. - it really seems like I broke the handling of strings. I guess in the past this correctly redirected to
text.txt
with two lines. In order for it to work, I now need to manually hand an explicit string:
So this works:
import shell
shell:
one:
mkdir foo
cd foo
"echo \"Hallo\nWorld\" > test.txt"
pipe:
cat test.txt
grep H
cd ".."
rm foo/test.txt
rmdir foo
I suppose I changed the string handling to make precisely this work. The idea being that a Nim string should just be handed "as is" in terms of the content to the shell. The example implies however, that the entire thing is handed as written to the shell. The latter is convenient in some cases (like here), but restricting in others (in the more common ones). Because we really need to be able to overwrite the limitations of the Nim grammar for many practical uses cases.