improve command-line options handling

Thanks to Martin Šťastný <stastny.m@gmail.com> for reporting this.

Signed-off-by: Jan Dvořák <mordae@anilinux.org>