Skip to content
Merged
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
2 changes: 1 addition & 1 deletion src/main/java/org/perlonjava/core/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public final class Configuration {
* Automatically populated by Gradle/Maven during build.
* DO NOT EDIT MANUALLY - this value is replaced at build time.
*/
public static final String gitCommitId = "4aafb6057";
public static final String gitCommitId = "a7261e446";

/**
* Git commit date of the build (ISO format: YYYY-MM-DD).
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/org/perlonjava/runtime/operators/IOOperator.java
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,14 @@ public static RuntimeScalar print(RuntimeList runtimeList, RuntimeScalar fileHan
try {
// Write the content to the file handle
return fh.write(sb.toString());
} catch (java.nio.channels.NonWritableChannelException e) {
// Writing to a read-only filehandle (opened with "<")
getGlobalVariable("main::!").set("Bad file descriptor");
WarnDie.warnWithCategory(
new RuntimeScalar("Filehandle opened only for input"),
new RuntimeScalar(""),
"io");
return new RuntimeScalar(); // undef
} catch (Exception e) {
getGlobalVariable("main::!").set("File operation failed: " + e.getMessage());
return scalarFalse;
Expand Down Expand Up @@ -779,6 +787,14 @@ public static RuntimeScalar say(RuntimeList runtimeList, RuntimeScalar fileHandl
return scalarFalse;
}
return fh.write(sb.toString());
} catch (java.nio.channels.NonWritableChannelException e) {
// Writing to a read-only filehandle (opened with "<")
getGlobalVariable("main::!").set("Bad file descriptor");
WarnDie.warnWithCategory(
new RuntimeScalar("Filehandle opened only for input"),
new RuntimeScalar(""),
"io");
return new RuntimeScalar(); // undef
} catch (Exception e) {
getGlobalVariable("main::!").set("File operation failed: " + e.getMessage());
return scalarFalse;
Expand Down
Loading