As you might know some modern programming languages support a ?. operator.
The ?. operator works just like the well-known . but has a built-in null-check, so myobj?.someMethod() is equivalent to if(myobj != null) myobj.someMethod()
In fish I've recently come across the pattern test -r file; and cmd < file which is very similar to the above example with the null-check replaced by a file-readability-test. My idea was to express this pattern simply as cmd <? file: If file is not readable, the command is skipped.
Interestingly the <? operator is already implemented in fish, however it's current behaviour is to fail if the file exists. As for as I can see for the stdin redirect this doesn't make any sense whatsoever.
Now that brings me to the consistency topic:
Currently, >? file fails noisily if file exists, while <? would skip quietly if file does not exist.
Would you consider changing the bahaviour of >? or rather suggest a different operator for <??
RFC
As you might know some modern programming languages support a
?.operator.The
?.operator works just like the well-known.but has a built-in null-check, somyobj?.someMethod()is equivalent toif(myobj != null) myobj.someMethod()In fish I've recently come across the pattern
test -r file; and cmd < filewhich is very similar to the above example with the null-check replaced by a file-readability-test. My idea was to express this pattern simply ascmd <? file: Iffileis not readable, the command is skipped.Interestingly the
<?operator is already implemented in fish, however it's current behaviour is to fail if the file exists. As for as I can see for the stdin redirect this doesn't make any sense whatsoever.Now that brings me to the consistency topic:
Currently,
>? filefails noisily iffileexists, while<?would skip quietly iffiledoes not exist.Would you consider changing the bahaviour of
>?or rather suggest a different operator for<??RFC