Handle closed standard input gracefully#27
Conversation
|
This doesn't quite work, as stdin is used in more than just the lines this PR hardens: For |
|
I gave up on |
0b2b082 to
49993e2
Compare
|
The failing tests are unrelated to this PR. It mentions |
|
Ready for review @ArrayBolt3 |
ArrayBolt3
left a comment
There was a problem hiding this comment.
Mostly good, only a few things I noticed that could use changed.
usr/bin/-
Outdated
There was a problem hiding this comment.
I think this file was created on accident.
| if stdin is not None: | ||
| for untrusted_text in stdin: | ||
| untrusted_text_list.append(untrusted_text) | ||
| if stdin is not None and len(argv) == 1: |
There was a problem hiding this comment.
Do we really want to always take the else branch here if stdin is None? I don't think we need the stdin check here. The tests also seem to pass for me if I remove the stdin check here.
run-tests
Outdated
| stdin_utils=(stcat stcatn sttee stsponge) | ||
| utils=(stprint stecho "${stdin_utils[@]}") | ||
| cd "${git_toplevel}/usr/bin" | ||
| "${black[@]}" -- "${utils[@]}" | ||
| "${pylint[@]}" -- "${utils[@]}" | ||
| for file in "${utils[@]}"; do | ||
| "${mypy[@]}" -- "${file}" | ||
| done | ||
|
|
||
| for util in "${stdin_utils[@]}"; do | ||
| ./"${util}" <&- | ||
| ./"${util}" - <&- | ||
| done |
There was a problem hiding this comment.
If either of sttee or stsponge are called as ./"${util}" - <&-, they will create a file named -. When running the tests, that ends up creating usr/bin/-, which is probably how that file got into thie PR. Can we divide stdin_utils a bit more so that we can skip the - argument for those two utils?
| utils=(stprint stecho stcat stcatn sttee stsponge) | ||
| stdin_utils_to_stdout=(stcat stcatn) | ||
| stdin_utils_to_file=(sttee stsponge) | ||
| utils=(stprint stecho "${stdin_utils[@]}") |
There was a problem hiding this comment.
| utils=(stprint stecho "${stdin_utils[@]}") | |
| utils=(stprint stecho "${stdin_utils_to_stdout[@]}" "${stdin_utils_to_file[@]}") |
There was a problem hiding this comment.
Other than this change, I think this is ready to merge.
ArrayBolt3
left a comment
There was a problem hiding this comment.
Looks good to me! @adrelanos Ready to merge.
This pull request changes...
Changes
Ignore NoneType stdin.
Mandatory Checklist
Terms of Service, Privacy Policy, Cookie Policy, E-Sign Consent, DMCA, Imprint
Optional Checklist
The following items are optional but might be requested in certain cases.
Fixes #26