summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/pkg18
1 files changed, 18 insertions, 0 deletions
diff --git a/bin/pkg b/bin/pkg
index 09c94af..a994354 100755
--- a/bin/pkg
+++ b/bin/pkg
@@ -24,6 +24,21 @@ info=$'\e[0;36m'
error=$'\e[0;31m'
reset=$'\e[0m'
+function debug {
+ if (( !DEBUG )) || (( SILENT )); then return; fi
+ typeset func line
+ if [[ ${#*} -ge 3 ]] {
+ func=$1
+ line=$2
+ shift 2
+ }
+ echo "(debug) $func:$line: $*"
+}
+
+# I need function name and line number of the function _calling_ debug,
+# so I can't get them from inside the debug function.
+alias debug='debug ${(%)$(echo %N)} ${(%)$(echo %i)}'
+
function info {
(( SILENT )) || echo -ne "${info}$*${reset}"
}
@@ -65,6 +80,7 @@ if [[ -f $HOME/.pkg.conf ]] {
: ${PDIR:="$HOME/packages"}
: ${CL_OPTIONS:=-q}
: ${SILENT=0}
+: ${DEBUG=0}
: ${AUTOUPDATE=1}
export PDIR
@@ -79,6 +95,8 @@ while [[ $1 == [-+]* ]] {
case $1 in
-q|--quiet) SILENT=1 ;;
+q|--no-quiiet) SILENT=0 ;;
+ -d|--debug) DEBUG=1 ;;
+ +d|--no-debug) DEBUG=0 ;;
-au|--auto-update) AUTOUPDATE=1 ;;
+au|--no-auto-update) AUTOUPDATE=0 ;;
-co|--checklinks-options) CL_OPTIONS+=$1; shift ;;