Assuming that the command only takes single letter options, and that none of the options takes an argument, we may create a wrapping script that parses the command line options, remove the unwanted options and executes the command given the new set of options:
#!/bin/sh
savedopts=-
printf 'Args in = %s\n' "$*"
while getopts :bc opt; do
case $opt in
b|c) ;; # nothing
*)
savedopts="$savedopts$OPTARG"
esac
done
shift "$(( OPTIND - 1 ))"
set -- "$savedopts" -- "$@"
printf 'Args out = %s\n' "$*"
# Run the command:
some-command "$@"
This parses the command line, ignores the options b and c, and puts the rest of the options into $savedopts.
$savedopts is then used to run the wrapped command, together with any operands given on the original command line (separated with --).
We don't get any errors from getopts even though we ask it to parse options that it may not expect. This is due to the initial : in the first argument to getopts.
Test run:
$ ./script -abcd -b -c -- -bx -a foo bar
Args in = -abcd -b -c -- -bx -a foo bar
Args out = -ad -- -bx -a foo bar
./script: some-command: not found
command -abc, how do you know it isn't a single option-awith an option-argumentbc(or-a -b c, i.e.-btakes an option-argument)? And what happens withcommand -abc -d -- -abc? With real command line parsing, removing-band-c, that should probably becomecommand -a -d -- -abc, assuming-atakes no argument, and regardless of whether-btakes an argument or not, right? If-atakes an argument, the command line options should remain unchanged, right?command --.