I am using bash shell
$cat test
a --b
$grep '--b' test
grep: option `--b' is ambiguous
Usage: grep [OPTION]... PATTERN [FILE]...
Try `grep --help' for more information.
$grep "--b" test
grep: option `--b' is ambiguous
Usage: grep [OPTION]... PATTERN [FILE]...
Try `grep --help' for more information.
$grep '\-\-b' test
a --b
The classic shell scripting book in chapter 7 “Input and Output,Files, and Command Evaluation” in section 7.7 Quoting says that
“Single quotes force the shell to treat everything between the pair of quotes literally”.
Then why is single quotes not working above?
The shell is treating them literally. But the shell is not responsible for how the application treats them. It is up to the application to decide how it wants to handle the
--bpassed as an argument.