Pipe (stdout) mode adds newline
Describe the bug
When writing the transfered content to a file or pipe using --stdout, the content is not equivalent to the original. Instead, the receiver command adds a trailing newline (\n, LF, hex: 0a).
To Reproduce
Steps to reproduce the behavior (Linux/Bash):
dd if=/dev/urandom of=binary_data_sent bs=1MB count=1random_secret=$RANDOM && echo $random_secretcroc --debug send --code $random_secret < binary_data_sentcroc --yes --stdout $random_secret > binary_data_receivedmd5sum binary_data_received binary_data_sentdiff <(xxd binary_data_sent) <(xxd binary_data_received)
Expected behaviour
- The md5 hash should be the same
- the diff shoult be empty
Version
v9.6.5-8ab65d0
happy to accept a PR for this, probably only need to change Println to Print
Probably, maybe, I don't know. I'm not using the software, just tested it for understanding and stumbled over this obvious bug.
https://github.com/schollz/croc/blob/ce91e3b420b47d26ea0c3c9d40e437b714c70e2d/src/croc/croc.go#L1087C1-L1102C3
I've identified the issue occurring at line 1101 in src/croc/croc.go. When the Stdout option is set to true, the code logic in this segment necessitates the deletion of the corresponding file and the output of a newline character at the end. It appears that this additional newline character is causing the problem. In my opinion, it would be more appropriate to direct the newline character output to os.Stderr in this context.
IMO, this issue can be closed.