rename subdir variable and guess the subdir name
work around %as GNU scanf extension
improve option parsing a bit