From c99d472ebba5cc994799dff8e0e7b2d48f34e7b5 Mon Sep 17 00:00:00 2001 From: Dylan Date: Sat, 30 Jan 2016 12:05:53 +1100 Subject: [PATCH] Added '--config off' and '--config none' to disable config files at launch --- 1.1.md | 3 ++- README.md | 8 +++++--- fetch | 27 ++++++++++++++++++++------- 3 files changed, 27 insertions(+), 11 deletions(-) diff --git a/1.1.md b/1.1.md index 29d90fd8..cf3515c0 100644 --- a/1.1.md +++ b/1.1.md @@ -13,7 +13,8 @@ - Fetch now has a config file that you can share with people and
keep between script versions! - Added `--config` and `$config_file` to specify a custom config location. -- Added `$config` to enable / disable config files +- Added `--config off`, `--config none` and `$config` to enable / disable config files
+at launch or in script. ### Info diff --git a/README.md b/README.md index acb68c11..1c287395 100644 --- a/README.md +++ b/README.md @@ -184,7 +184,7 @@ alias fetch2="fetch \ ## Usage - usage: ${0##*/} --option "value" --option + usage: ${0##*/} --option "value" Info: --osx_buildversion Hide/Show Mac OS X build version. @@ -257,9 +257,9 @@ alias fetch2="fetch \ Ascii: --ascii Where to get the ascii from, Possible values: - 'distro', '/path/to/ascii' + distro, /path/to/ascii --ascii_color Color to print the ascii art - --ascii_distro distro Which Distro's ascii art to print + --ascii_distro distro Which Distro\'s ascii art to print Screenshot: @@ -269,6 +269,8 @@ alias fetch2="fetch \ --scrot_cmd Screenshot program to launch Other: + --config Specify a path to a custom config file + --config none Launch the script without a config file --help Print this text and exit diff --git a/fetch b/fetch index 60db492e..07a1bd75 100755 --- a/fetch +++ b/fetch @@ -1744,6 +1744,7 @@ getscriptdir () { # Check for $config_file first getconfig () { + # Check $config_file if [ -f "$config_file" ]; then source "$config_file" return @@ -1768,6 +1769,14 @@ getconfig () { fi } +# Check the commandline flags early for '--config none/off' +case "$@" in + *"--config off"* | *'--config "off"'* | *"--config 'off'"* | \ + *"--config none"* | *'--config "none"'* | *"--config 'none'"*) + config="off" + ;; +esac + # If config files are enabled [ "$config" == "on" ] && getconfig @@ -1868,6 +1877,8 @@ usage () { cat << EOF --scrot_cmd Screenshot program to launch Other: + --config Specify a path to a custom config file + --config none Launch the script without a config file --help Print this text and exit EOF @@ -1926,9 +1937,7 @@ while [ "$1" ]; do [ -z "$2" ] && image="ascii" case "$2" in - "--"*) - image="ascii" - ;; + "--"*) image="ascii" ;; esac ;; @@ -1949,9 +1958,7 @@ while [ "$1" ]; do [ -z "$2" ] && ascii="distro" case "$2" in - "--"*) - ascii="distro" - ;; + "--"*) ascii="distro" ;; esac ;; @@ -1964,7 +1971,13 @@ while [ "$1" ]; do --scrot_cmd) scrot_cmd="$2" ;; # Other - --config) config_file="$2"; getconfig ;; + --config) + case "$2" in + "none" | "off") config="off" ;; + *) config_file="$2"; config="on"; getconfig ;; + esac + ;; + --help) usage ;; esac