From 5a0264d89460ae5a5b4723c9afd46703add299dc Mon Sep 17 00:00:00 2001 From: emmett1 Date: Sat, 29 Jul 2017 12:49:38 +0800 Subject: [PATCH] add no color function --- buildpkg | 8 ++++++++ functions | 20 ++++++++++++++++++++ installpkg | 8 ++++++++ removepkg | 8 ++++++++ scratch | 8 ++++++++ 5 files changed, 52 insertions(+) diff --git a/buildpkg b/buildpkg index 96e59c7..e300da4 100755 --- a/buildpkg +++ b/buildpkg @@ -435,6 +435,9 @@ parse_options() { -cc|--check-checksum) CHECK_CHECKSUM=yes ;; + --no-color) + NO_COLOR=yes + ;; -sd|--source-dir) if [ ! "$2" ]; then msg "Option '$1' require an argument (source path for package)." @@ -475,6 +478,11 @@ main() { parse_options "$@" + ### DISABLE COLOR ### + if [ "$NO_COLOR" ]; then + nocolor + fi + ### SET OUTPUT PATH FOR PACKAGE ### if [ $OUTPUT_PKG ]; then PACKAGE_DIR="$OUTPUT_PKG" diff --git a/functions b/functions index 05d8f1a..5c028bd 100644 --- a/functions +++ b/functions @@ -60,6 +60,26 @@ rm_silent() { command rm -d "$@" 2> /dev/null } +nocolor() { + + color_red='' + color_green='' + color_yellow='' + color_blue='' + color_purple='' + color_cyan='' + color_gray='' + color_bred='' + color_bgreen='' + color_byellow='' + color_bblue='' + color_bpurple='' + color_bcyan='' + color_bgray='' + color_reset='' + +} + updatesystemdb() { # update desktop database diff --git a/installpkg b/installpkg index 5e6ce54..fc37477 100755 --- a/installpkg +++ b/installpkg @@ -276,6 +276,9 @@ parse_options() { --no-backup) NO_BACKUP=yes ;; + --no-color) + NO_COLOR=yes + ;; *.spkg.txz) [ -f $1 ] && PKGNAME=$1 || msg "${color_red}$1${color_reset} not exist." ;; @@ -295,6 +298,11 @@ main() { parse_options "$@" + ### DISABLE COLOR ### + if [ "$NO_COLOR" ]; then + nocolor + fi + ### LOAD CONFIGURATION FILE ### if [ -f $CONF_FILE ]; then . $CONF_FILE diff --git a/removepkg b/removepkg index 04b9f4b..7ce6825 100755 --- a/removepkg +++ b/removepkg @@ -151,6 +151,9 @@ parse_options() { --no-postremove) NO_POSTREMOVE=yes ;; + --no-color) + NO_COLOR=yes + ;; *) RMNAME=$1 ;; @@ -166,6 +169,11 @@ main() { parse_options "$@" + ### DISABLE COLOR ### + if [ "$NO_COLOR" ]; then + nocolor + fi + ### LOAD CONFIGURATION FILE ### if [ -f $CONF_FILE ]; then . $CONF_FILE diff --git a/scratch b/scratch index 8c78bb9..83c3202 100755 --- a/scratch +++ b/scratch @@ -362,6 +362,9 @@ parse_options() { --sync) SYNC_PORTS=yes ;; + --no-color) + NO_COLOR=yes + ;; -dp|--dependent) if [ ! "$2" ]; then info "Option '$1' require an argument (package to show its dependent)" @@ -441,6 +444,11 @@ main() { parse_options "$@" + ### DISABLE COLOR ### + if [ "$NO_COLOR" ]; then + nocolor + fi + ### LOAD CONFIGURATION FILE ### if [ -f $CONF_FILE ]; then . $CONF_FILE