There is an out-of-bounds error on Windows when using os.listdir("")
which could result in indeterminate behaviour. After parsing the args, it
does
ch = namebuf[len-1];
which indexes before the array as len = 0.
Possibly change this to
ch = (len > 0) ? namebuf[len-1] : '\0';
Neil