Fabian Boehm 20243132fb Add <? input redirection
This tries to open the given file to use as stdin, and if it fails,
for any reason, it uses /dev/null instead.

This is useful in cases where we would otherwise do either of these:

```fish
test -r /path/to/file
and string match foo < /path/to/file

cat /path/to/file 2>/dev/null | string match foo
```

This both makes it nicer and shorter, *and* helps with TOCTTOU - what if the file is removed/changed after the check?

The reason for reading /dev/null instead of a closed fd is that a closed fd will often cause an error.

In case opening /dev/null fails, it still skips the command.
That's really a last resort for when the operating system
has turned out to be a platypus and not a unix.

Fixes #4865

(cherry picked from commit df8b9b70954fd38c170b954967112d50ba299223)
2024-04-21 14:35:13 +02:00
..
2023-07-09 14:11:01 +08:00
2024-04-20 13:34:08 +02:00
2022-09-17 21:31:06 +08:00
2023-08-23 23:08:56 +02:00
2024-04-20 17:05:46 +02:00
2024-04-21 14:35:13 +02:00
2024-01-30 18:18:55 +08:00
2024-02-03 11:12:11 +01:00