GitHubのミラーです
https://github.com/Hayao0819/wfa
Revisión | 97ea9a06ffdfec394497569c2e876e7747ce0ef4 (tree) |
---|---|
Tiempo | 2020-12-24 15:24:56 |
Autor | hayao <shun819.mail@gmai...> |
Commiter | hayao |
[update] : Use function to check operation
@@ -827,6 +827,16 @@ check_installed_package() { | ||
827 | 827 | fi |
828 | 828 | } |
829 | 829 | |
830 | +# 引数で渡されたオペレーションが指定されている場合のみ正常終了します。 | |
831 | +check_operation() { | |
832 | + local _operation="${1}" | |
833 | + if [[ "${_operation}" = "${operation}" ]]; then | |
834 | + return 0 | |
835 | + else | |
836 | + return 1 | |
837 | + fi | |
838 | +} | |
839 | + | |
830 | 840 | # ~/.cacheに相当するディレクトリを返します |
831 | 841 | get_cache_dir() { |
832 | 842 | local _user_config_dir _cache_dir |
@@ -1324,7 +1334,8 @@ while :; do | ||
1324 | 1334 | -s | --search | --recursive) |
1325 | 1335 | case "${1}" in |
1326 | 1336 | --search) |
1327 | - if [[ "${operation}" = "sync" ]]; then | |
1337 | + #if [[ "${operation}" = "sync" ]]; then | |
1338 | + if check_operation "sync"; then | |
1328 | 1339 | add_args pacman "--search" |
1329 | 1340 | sync_search=true |
1330 | 1341 | else |
@@ -1332,7 +1343,8 @@ while :; do | ||
1332 | 1343 | fi |
1333 | 1344 | ;; |
1334 | 1345 | --recursive) |
1335 | - if [[ "${operation}" = "remove" ]]; then | |
1346 | + #if [[ "${operation}" = "remove" ]]; then | |
1347 | + if check_operation "rmeove"; then | |
1336 | 1348 | add_args pacman "--recursive" |
1337 | 1349 | else |
1338 | 1350 | unavailable_in_this_operation |
@@ -1358,14 +1370,16 @@ while :; do | ||
1358 | 1370 | -u | --sysupgrade | --unneeded) |
1359 | 1371 | case "${1}" in |
1360 | 1372 | --sysupgrade) |
1361 | - if [[ "${operation}" = "sync" ]]; then | |
1373 | + #if [[ "${operation}" = "sync" ]]; then | |
1374 | + if check_operation "sync"; then | |
1362 | 1375 | sync_upgrade=true |
1363 | 1376 | else |
1364 | 1377 | unavailable_in_this_operation |
1365 | 1378 | fi |
1366 | 1379 | ;; |
1367 | 1380 | --unneeded) |
1368 | - if [[ "${operation}" = "remove" ]]; then | |
1381 | + #if [[ "${operation}" = "remove" ]]; then | |
1382 | + if check_operation "rmeove"; then | |
1369 | 1383 | add_args pacman "--unneeded" |
1370 | 1384 | else |
1371 | 1385 | unavailable_in_this_operation |
@@ -1393,14 +1407,16 @@ while :; do | ||
1393 | 1407 | -c | --clean | --cascade) |
1394 | 1408 | case "${1}" in |
1395 | 1409 | --clean) |
1396 | - if [[ "${operation}" = "sync" ]]; then | |
1410 | + #if [[ "${operation}" = "sync" ]]; then | |
1411 | + if check_operation "sync"; then | |
1397 | 1412 | sync_clean_count=$(( sync_clean_count + 1 )) |
1398 | 1413 | else |
1399 | 1414 | unavailable_in_this_operation |
1400 | 1415 | fi |
1401 | 1416 | ;; |
1402 | 1417 | --cascade) |
1403 | - if [[ "${operation}" = "remove" ]]; then | |
1418 | + #if [[ "${operation}" = "remove" ]]; then | |
1419 | + if check_operation "rmeove"; then | |
1404 | 1420 | add_args pacman "--cascade" |
1405 | 1421 | else |
1406 | 1422 | unavailable_in_this_operation |