From 040b3fe3bb9b0862c28e0a9fc7a70e5c46844c7b Mon Sep 17 00:00:00 2001 From: boyska Date: Mon, 31 Oct 2011 23:34:21 +0100 Subject: [PATCH] FIX #59 : --no-color do as expected includes documentation for --no-color --- doc/tomb.1 | 4 ++++ src/tomb | 10 ++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/doc/tomb.1 b/doc/tomb.1 index 5edfa98..d989542 100644 --- a/doc/tomb.1 +++ b/doc/tomb.1 @@ -135,8 +135,12 @@ Display version and quit .B .IP "-q" Run more quietly +.B .IP "-D" Print more information while running, for debugging purposes +.B +.IP "--no-color" +Don't use colors; useful for old terminals or integration in other scripts .SH HOOKS diff --git a/src/tomb b/src/tomb index f126fec..5668098 100755 --- a/src/tomb +++ b/src/tomb @@ -37,8 +37,6 @@ typeset -A opts # PATH=/usr/bin:/usr/sbin:/bin:/sbin -autoload colors; colors - # standard output message routines # it's always useful to wrap them, in case we change behaviour later notice() { if [[ $QUIET == 0 ]]; then print "$fg_bold[green][*]$fg_no_bold[white] $1" >&2; fi } @@ -1247,8 +1245,8 @@ main() { # There are two reasons for that: # I. usability; user expect that "-s" is "size # II. Option parsing WILL EXPLODE if you do this kind of bad things - # (it will say "option defined more than once, and he's right) - main_opts=(q -quiet=q D -debug=D h -help=h v -version=v) + # (it will say "option defined more than once, and he's right") + main_opts=(q -quiet=q D -debug=D h -help=h v -version=v -no-color) subcommands_opts[__default]="" subcommands_opts[open]="n -nohook=n k: -key=k o: -mount-options=o -ignore-swap" subcommands_opts[mount]=${subcommands_opts[open]} @@ -1321,6 +1319,10 @@ main() { fi ### End parsing command-specific options + if ! option_is_set --no-color; then + autoload colors; colors + fi + ### Set global options (useless, but for code retro-compatibility) for opt in ${(k)global_opts}; do if [[ $opt == '-q' ]]; then