diff options
author | Daniel Friesel <derf@derf.homelinux.org> | 2009-06-18 12:28:44 +0200 |
---|---|---|
committer | Daniel Friesel <derf@derf.homelinux.org> | 2009-06-18 12:28:46 +0200 |
commit | 267a339bfd548169b54c5ae1b3070477f8c4b91f (patch) | |
tree | 105cead555087957cd4b43c28185607a3f7b7d4c /bin | |
parent | 8fed4324fd1d5135d6cfff1b163c98416c5530ae (diff) |
pkg: Restructured the beginnig of the program
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/pkg | 49 |
1 files changed, 22 insertions, 27 deletions
@@ -18,28 +18,10 @@ setopt extended_glob typeset -a -U triggers typeset -a CL_OPTIONS -## -## Internal functions for displaying stuff -## - c_info=$'\e[0;36m' c_error=$'\e[0;31m' c_reset=$'\e[0m' -function debug { - typeset func line - if (( $# >= 3 )) { - func=$1 - line=$2 - shift 2 - } - echo "(debug) $func:$line: $*" >&2 -} - -# 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 ${(z%):-%N %i}' - function info { echo -ne "${c_info}$*${c_reset}" } @@ -57,14 +39,6 @@ function say { echo $* } -function check_installed { - [[ -n $1 && -d $PKG_DIR/$1 ]] || die "Package not installed: '$1'\n" -} - -function check_valid { - list_exists $1 || die "Package does not exist: '$1'\n" -} - function clear_line { echo -ne "\r\e[2K" } @@ -107,6 +81,20 @@ shift export PKG_DIR export PKG_ROOT +function debug { + typeset func line + if (( $# >= 3 )) { + func=$1 + line=$2 + shift 2 + } + echo "(debug) $func:$line: $*" >&2 +} + +# 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 ${(z%):-%N %i}' + # Avoid calling debug without debug mode... just in case one needs more speed if (( !DEBUG )) { unalias debug @@ -122,7 +110,6 @@ if (( SILENT )) { function clear_line {} } - if [[ ! -d $PKG_DIR ]] { die "Error: Package directory '$PKG_DIR' not found\n" } @@ -176,6 +163,14 @@ if ((DEBUG)) { echo " GIT_USE_ORIGIN $GIT_USE_ORIGIN" } +function check_installed { + [[ -n $1 && -d $PKG_DIR/$1 ]] || die "Package not installed: '$1'\n" +} + +function check_valid { + list_exists $1 || die "Package does not exist: '$1'\n" +} + # Default reply: Yes function confirm_yes { echo -n "$* [Y/n] " |