Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
6 changed files
with
86 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters