【发布时间】:2015-10-09 22:29:28
【问题描述】:
如果一个 getopts 标志设置为 true,我如何让另一个标志根据它来行动?
option_r=false
option_v=false
while getopts 'r:v' option
do
case "$option" in
r) option_r=true
*Just to set the flag to true*
;;
v) option_v=true
if *option -r is set to true*
then
cp -r directory1 directory2
if *option -r is set to false*
then
cp directory1 directory2 (copy normally)
;;
我希望我正确地解释了自己。
基本上,如果一个标志打开,我希望它反映在另一个选项上。如果选项 -r 处于活动状态,则递归复制,否则,正常复制。
提前致谢!
【问题讨论】: