Skip to content

Commit 710e669

Browse files
committed
FIX: echo does not error on bad path
resolves: Oldes/Rebol-issues#693
1 parent d066e25 commit 710e669

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

src/core/d-print.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -512,12 +512,12 @@ static REBREQ *Req_SIO;
512512

513513
/***********************************************************************
514514
**
515-
*/ REBFLG Echo_File(REBCHR *file)
515+
*/ REBINT Echo_File(REBCHR *file)
516516
/*
517517
***********************************************************************/
518518
{
519519
Req_SIO->file.path = file;
520-
return (DR_ERROR != OS_DO_DEVICE(Req_SIO, RDC_CREATE));
520+
return OS_DO_DEVICE(Req_SIO, RDC_CREATE);
521521
}
522522

523523

src/core/n-io.c

+6-1
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ static REBSER *Read_All_File(char *fname)
8282
{
8383
REBVAL *val = D_ARG(1);
8484
REBSER *ser = 0;
85+
REBINT err;
8586

8687
Echo_File(0);
8788

@@ -91,7 +92,11 @@ static REBSER *Read_All_File(char *fname)
9192
ser = To_Local_Path("output.txt", 10, FALSE, TRUE);
9293

9394
if (ser) {
94-
if (!Echo_File((REBCHR*)(ser->data))) Trap1(RE_CANNOT_OPEN, val);
95+
err = Echo_File((REBCHR *)(ser->data));
96+
if (err != DR_DONE) {
97+
SET_INTEGER(D_RET, -err);
98+
Trap2(RE_CANNOT_OPEN, val, D_RET);
99+
}
95100
}
96101

97102
return R_RET;

src/tests/units/file-test.r3

+13
Original file line numberDiff line numberDiff line change
@@ -130,4 +130,17 @@ secure [%/ allow]
130130

131131
===end-group===
132132

133+
134+
===start-group=== "ECHO"
135+
--test-- "echo test"
136+
echo %echo-result print 1 echo none
137+
--assert "1^/" = read/string %echo-result
138+
139+
--test-- "echo failed"
140+
;@@ https://github.com/Oldes/Rebol-issues/issues/834
141+
--assert all [error? e: try [echo %not-existing-dir/foo] e/id = 'cannot-open]
142+
===end-group===
143+
144+
echo %/r/sss/xxxx
145+
133146
~~~end-file~~~

0 commit comments

Comments
 (0)