astrand / xclip

Command line interface to the X11 clipboard
GNU General Public License v2.0
1.03k stars 73 forks source link

proper stdio error handling #153

Open nabijaczleweli opened 1 month ago

nabijaczleweli commented 1 month ago

Correctly detect errors from stdio:

$ ./xclip < .
./xclip: (stdin): Is a directory
$ ./xclip .
./xclip: .: Is a directory
$ xclip .
^C

also, by reordering the loop and the condition this way, we only allocate more if we know there's more, and only check for EOF if we encountered an EOF or error.