改变线,
dbPassword=exam!ple#####
至,
dbPassword='exam!ple#####'
避免 ! (历史扩张)在bash中被特别对待
从QUOTING子节下的man bash,
When the command history expansion facilities are being used (see HISTORY EXPANSION below), the history expansion character, usually !, must be quoted to prevent history expansion.
在历史扩张下更多
History expansions are introduced by
the appearance of the history expansion character, which is ! by
default. Only backslash (\) and single quotes can quote the history
expansion character.
此外,最好引用所有名称 – 值对以防止shell完成分词.
sh home/example.sh --context_param dbUserName="username" --context_param dbPassword='exam!ple#####' --context_param resultDate="2017-01-13"
关于分词,从手册页,
Word Splitting
The shell scans the results of parameter expansion, command substitution, and arithmetic expansion that did not occur within double quotes for word splitting. The shell treats each character of IFS as a delimiter, and splits the results of the other expansions into words using these characters as field terminators