Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions M2/Macaulay2/d/stdio.d
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,7 @@ export closeListener(o:file):(errmsg or null) := (
null());

export closeIn(o:file):(errmsg or null) := (
if o == stdIO then return errmsg("can't close stdio");
stat := 0;
if o.infd == NOFD then return errmsg("close: file not open");
if o == stdIO then return null(); -- silently refuse to close stdIO
Expand All @@ -538,6 +539,8 @@ export closeIn(o:file):(errmsg or null) := (
null());

export closeOut(o:file):(errmsg or null) := (
if o == stdIO then return errmsg("can't close stdio");
if o == stdError then return errmsg("can't close stderr");
stat := 0;
if o.outfd == NOFD then return errmsg("close: file not open");
haderror := false;
Expand Down
4 changes: 4 additions & 0 deletions M2/Macaulay2/tests/normal/files.m2
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@ assert(baseFilename "foo////" == "foo")
assert(baseFilename "" == "")
assert(baseFilename "/" == "/")
assert(baseFilename "////" == "/")

-- issue #4392
assert try stdio << close then false else true
assert try stderr << close then false else true