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 `shift`s into account. This is based on the following SO answer: <https://stackoverflow.com/a/7069755/3452708>
2.2 KiB
Executable File
2.2 KiB
Executable File