mirror of
https://github.com/tanakh/cmdline.git
synced 2024-11-21 01:14:06 +08:00
fix short option always eat next argument
This commit is contained in:
parent
a27c759a73
commit
b177d663d0
12
cmdline.h
12
cmdline.h
@ -287,13 +287,13 @@ public:
|
||||
continue;
|
||||
}
|
||||
|
||||
if (i+1>=argc || strncmp(argv[i+1], "-", 1)==0 ||
|
||||
!options[lookup[last]]->has_value()){
|
||||
set_option(lookup[last]);
|
||||
continue;
|
||||
if (i+1<argc && options[lookup[last]]->has_value()){
|
||||
set_option(lookup[last], argv[i+1]);
|
||||
i++;
|
||||
}
|
||||
else{
|
||||
set_option(lookup[last]);
|
||||
}
|
||||
set_option(lookup[last], argv[i+1]);
|
||||
i++;
|
||||
}
|
||||
else{
|
||||
others.push_back(argv[i]);
|
||||
|
Loading…
Reference in New Issue
Block a user