0
如果一個getopts標誌設置爲true,我該如何根據它做出另一個標誌?如果一個getopts標誌處於活動狀態,如何使另一個標誌以某種方式運行?
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處於活動狀態,則遞歸複製,否則正常複製。
在此先感謝!
這是因爲'getopts'不關心必要的,這責令選項進來你必須同時迎合'命令-r -v'和'命令-v -r' – rojomoke