rien / reStream

Stream your reMarkable screen over SSH.
MIT License
734 stars 56 forks source link

Fix incorrect handling of flags #12

Closed matteodelabre closed 4 years ago

matteodelabre commented 4 years ago

Previously, arguments were examined by a for loop, but this loop is not affected by the shift commands executed inside of it.

Because the loop always advances one argument further on each iteration, this bug goes unnoticed with the --portrait option (shift is called once, which matches the behavior of the loop). However, handling of the --destination argument is broken because of that (shift is called twice but the loop only advances one argument).

This commit replaces the for loop by a while loop which always examines the next argument and properly takes shifts into account. This is based on the following SO answer: https://stackoverflow.com/a/7069755/3452708