OSDN Git Service

[update] : Added --bash-debug
authorhayao <shun819.mail@gmail.com>
Sun, 20 Dec 2020 05:19:28 +0000 (14:19 +0900)
committerhayao <shun819.mail@gmail.com>
Sun, 20 Dec 2020 05:19:28 +0000 (14:19 +0900)
wfa

diff --git a/wfa b/wfa
index 03544ef..7b183a4 100755 (executable)
--- a/wfa
+++ b/wfa
@@ -17,6 +17,7 @@ aururl="https://aur.archlinux.org/"
 operation="none"
 
 #-- options (bool) --#
+bash_debug=false
 debug=false
 force_aur=false
 msgdebug=false
@@ -324,6 +325,9 @@ msg() {
 # Show an INFO message
 # $1: message string
 msg_info() {
+    if [[ "${msgdebug}" = false ]]; then
+        set +xv
+    fi
     local _msg_opts="-a ${wfa_name}"
     if [[ "${1}" = "-n" ]]; then
         _msg_opts="${_msg_opts} -o -n"
@@ -332,11 +336,17 @@ msg_info() {
     [[ "${msgdebug}" = true ]] && _msg_opts="${_msg_opts} -x"
     [[ "${nocolor}"  = true ]] && _msg_opts="${_msg_opts} -n"
     msg ${_msg_opts} info "${1}"
+    if [[ "${bash_debug}" = true ]]; then
+        set -xv
+    fi
 }
 
 # Show an Warning message
 # $1: message string
 msg_warn() {
+    if [[ "${msgdebug}" = false ]]; then
+        set +xv
+    fi
     local _msg_opts="-a ${wfa_name}"
     if [[ "${1}" = "-n" ]]; then
         _msg_opts="${_msg_opts} -o -n"
@@ -345,11 +355,17 @@ msg_warn() {
     [[ "${msgdebug}" = true ]] && _msg_opts="${_msg_opts} -x"
     [[ "${nocolor}"  = true ]] && _msg_opts="${_msg_opts} -n"
     msg ${_msg_opts} warn "${1}"
+    if [[ "${bash_debug}" = true ]]; then
+        set -xv
+    fi
 }
 
 # Show an debug message
 # $1: message string
 msg_debug() {
+    if [[ "${msgdebug}" = false ]]; then
+        set +xv
+    fi
     if [[ "${debug}" = true ]]; then
         local _msg_opts="-a ${wfa_name}"
         if [[ "${1}" = "-n" ]]; then
@@ -360,12 +376,18 @@ msg_debug() {
         [[ "${nocolor}"  = true ]] && _msg_opts="${_msg_opts} -n"
         msg ${_msg_opts} debug "${1}"
     fi
+    if [[ "${bash_debug}" = true ]]; then
+        set -xv
+    fi
 }
 
 # Show an ERROR message then exit with status
 # $1: message string
 # $2: exit code number (with 0 does not exit)
 msg_error() {
+    if [[ "${msgdebug}" = false ]]; then
+        set +xv
+    fi
     local _msg_opts="-a ${wfa_name}"
     if [[ "${1}" = "-n" ]]; then
         _msg_opts="${_msg_opts} -o -n"
@@ -377,6 +399,9 @@ msg_error() {
     if [[ -n "${2:-}" ]]; then
         exit ${2}
     fi
+    if [[ "${bash_debug}" = true ]]; then
+        set -xv
+    fi
 }
 
 # rm helper
@@ -794,7 +819,7 @@ operation_sync(){
 # Parse options
 ARGUMENT="${@}"
 _opt_short="QRShVdb:ay"
-_opt_long="query,remove,sync,help,version,debug,dbpath:,aururl,aur,noconfirm,config:,makepkg:,mflags:,pacman:,git:,gitflags:,gpg:,gpgflags:,makepkgconf:,nomakepkgconf,nodeps,refresh"
+_opt_long="query,remove,sync,help,version,debug,dbpath:,aururl,aur,noconfirm,config:,makepkg:,mflags:,pacman:,git:,gitflags:,gpg:,gpgflags:,makepkgconf:,nomakepkgconf,nodeps,refresh,bash-debug"
 
 OPT=$(getopt -o ${_opt_short} -l ${_opt_long} -- ${ARGUMENT})
 [[ ${?} != 0 ]] && exit 1
@@ -905,6 +930,11 @@ while :; do
             nomakepkgconf=true
             shift 1
         ;;
+        --bash-debug)
+            bash_debug=true
+            set -xv
+            shift 1
+            ;;
         -h | --help)
             usage
             shift 1