Fix an error when running --only
or --except
options
#7905
Merged
--only
or --except
options
#7905