Skip to content

Commit 64063dc

Browse files
authored
Fix read_file on Bash's process substitution (#1584)
See: sourcemeta/jsonschema#252 Signed-off-by: Juan Cruz Viotti <[email protected]>
1 parent 4cb5ab6 commit 64063dc

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/core/json/json.cc

+6-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,12 @@ auto read_file(const std::filesystem::path &path)
4343
std::make_error_code(std::errc::is_a_directory));
4444
}
4545

46-
std::ifstream stream{std::filesystem::canonical(path)};
46+
std::ifstream stream{
47+
// On Linux, FIFO files (like /dev/fd/XX due to process substitution)
48+
// cannot be
49+
// made canonical
50+
// See https://github.com/sourcemeta/jsonschema/issues/252
51+
std::filesystem::is_fifo(path) ? path : std::filesystem::canonical(path)};
4752
stream.exceptions(std::ifstream::failbit | std::ifstream::badbit);
4853
assert(!stream.fail());
4954
assert(stream.is_open());

0 commit comments

Comments
 (0)