Skip to content

Commit a976435

Browse files
committed
fix(cli): when taking input from stdin, clearly separate the lines instead of concatenating everything (resulting in comments being longer than expected)
1 parent a63d477 commit a976435

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ jobs:
206206
CODE='(import std.Sys) (if (!= ["1" "2" "3"] sys:args) { (print sys:args) (sys:exit 1) })'
207207
echo $CODE > a.ark
208208
rm -rf __arkscript__
209-
209+
210210
./build/arkscript -fno-cache a.ark 1 2 3
211211
# -fno-cache should prevent the cache creation
212212
if [ -d __arkscript__ ]; then
@@ -220,7 +220,7 @@ jobs:
220220
CODE='(import std.Sys) (if (!= ["1" "2" "3"] sys:args) { (print sys:args) (sys:exit 1) })'
221221
echo $CODE > a.ark
222222
rm -rf __arkscript__
223-
223+
224224
./build/arkscript - 1 2 3 <a.ark
225225
# we read from stdin, there should be no cache created
226226
if [ -d __arkscript__ ]; then
@@ -234,6 +234,7 @@ jobs:
234234
rm -rf __arkscript__
235235
236236
./build/arkscript - 1 2 3 << EOF
237+
# test comment, should be on its own line and not hide the following import
237238
(import std.Sys)
238239
(if (!= ["1" "2" "3"] sys:args)
239240
{

src/arkscript/main.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -253,9 +253,7 @@ int main(int argc, char** argv)
253253

254254
if (file == "-")
255255
{
256-
std::string content, line;
257-
while (std::getline(std::cin, line))
258-
content += line;
256+
std::string content(std::istreambuf_iterator<char>(std::cin), {});
259257
if (!state.doString(content, passes))
260258
return ArkErrorExitCode;
261259
}

0 commit comments

Comments
 (0)