Global Feed Post Login
Replying to Avatar fiatjaf

Suppose you're using a CLI too that takes multiline input from stdin and processes it one line at a time, printing the results of each line sequentially.

What is the correct behavior in case one of these stdin lines causes an error? To immediately halt the execution or to print an error message to stderr and continue on the next line? Do you have an example of a CLI tool that does it right?

Avatar
Chris 2y ago

grep "apple" nonexistent.txt sample.txt

grep: nonexistent.txt: No such file or directory

sample.txt:apple

sample.txt:apple pie

sed and awk should behave similarly.

Reply to this note

Please Login to reply.

Discussion

Avatar
Chris 2y ago

This isn’t really multiline tho. So nvm

Thread collapsed