From 70e74768b5329dba314f238c9908b35f7030cf87 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 16 Dec 2016 10:03:44 +1100 Subject: [PATCH 1/6] Args: Fix config bug and remove large case for single regex match --- neofetch | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/neofetch b/neofetch index f4551dab..9693e863 100755 --- a/neofetch +++ b/neofetch @@ -2704,8 +2704,7 @@ color() { # OTHER err() { - err+="$(color 1)[!]\033[0m $1 -" + err+="$(color 1)[!]\033[0m $1\n" } get_script_dir() { @@ -3134,17 +3133,7 @@ exit 1 get_args() { # 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" - ;; - - *"--config -"*) ;; - *"--config"*) config="off" ;; - esac - - [[ "${config:-on}" == "on" ]] && get_user_config 2>/dev/null + [[ "$@" =~ \-\-config\ ?(off|none) ]] || get_user_config 2>/dev/null while [[ "$1" ]]; do case "$1" in @@ -3291,7 +3280,7 @@ get_args() { # Other "--config") case "$2" in - "none" | "off") config="off" ;; + "none" | "off" | "") config="off" ;; *) config_file="$2"; config="on"; get_user_config 2>/dev/null ;; esac ;; From 3bbe52b93bf12b416d6375fc15cf769c49bf984b Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 16 Dec 2016 12:50:39 +1100 Subject: [PATCH 2/6] Args: Fix regex --- neofetch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neofetch b/neofetch index 9693e863..23b731d5 100755 --- a/neofetch +++ b/neofetch @@ -3133,7 +3133,7 @@ exit 1 get_args() { # Check the commandline flags early for '--config none/off' - [[ "$@" =~ \-\-config\ ?(off|none) ]] || get_user_config 2>/dev/null + [[ "$@" =~ --config\ ?(off|none) ]] || get_user_config 2>/dev/null while [[ "$1" ]]; do case "$1" in From 6da7ab06f1567c6a13422168fde44b00c06d3a4f Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 16 Dec 2016 13:20:10 +1100 Subject: [PATCH 3/6] General: Remove printf subshells --- neofetch | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/neofetch b/neofetch index 23c6f1dc..c75cacc1 100755 --- a/neofetch +++ b/neofetch @@ -1798,7 +1798,7 @@ get_birthday() { get_cols() { if [[ "$color_blocks" == "on" ]]; then # Convert the width to space chars. - block_width="$(printf "%${block_width}s")" + printf -v block_width "%${block_width}s" block_width="${block_width// /█}" # Generate the string. @@ -1811,7 +1811,7 @@ get_cols() { done # Convert height into spaces. - spaces="$(printf "%${block_height}s")" + printf -v spaces "%${block_height}s" # Convert the spaces into rows of blocks. [[ "$blocks" ]] && cols+="${spaces// /${blocks}${reset}nl}" @@ -1850,7 +1850,7 @@ get_image_backend() { *) if [[ -d "$image_source" ]]; then files=("${image_source%/}"/*.{png,jpg,jpeg}) - image="$(printf "%s" "${files[RANDOM % (${#files[@]} - 1)]}")" + printf -v image "%s" "${files[RANDOM % (${#files[@]} - 1)]}" else image="$image_source" fi @@ -2418,7 +2418,7 @@ prin() { get_underline() { if [[ "$underline_enabled" == "on" ]]; then - underline="$(printf %"$length"s)" + printf -v underline "%${length}s" underline="${underline_color}${underline// /$underline_char}" unset -v length fi @@ -2792,8 +2792,8 @@ bar() { elapsed="$(($1 * bar_length / $2))" # Create the bar with spaces - prog="$(printf %"$elapsed"s)" - total="$(printf %"$((bar_length - elapsed))"s)" + printf -v prog "%${elapsed}s" + printf -v total "%$((bar_length - elapsed))s" # Set the colors and swap the spaces for $bar_char_ bar+="${bar_color_elapsed}${prog// /$bar_char_elapsed}" From 046305f97b3dc90fc59e67ce4d8f15cbc197cda3 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 16 Dec 2016 13:25:58 +1100 Subject: [PATCH 4/6] Update CHANGELOG.md --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 26930ac8..0cfe5b56 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -100,3 +100,8 @@ Neofetch now has an irc channel at `#neofetch` on Freenode. If you have any ques ## Screenshot - Use arrays for `$scrot_program` + +## Args + +- Fixed bug where `neofetch --config` sourced the user config twice. +- Cleaned up config arg handling. From 595f765b4d118b02b2e9d6e350f0230695d7daf7 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 16 Dec 2016 13:26:08 +1100 Subject: [PATCH 5/6] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0cfe5b56..aaebb254 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -101,6 +101,7 @@ Neofetch now has an irc channel at `#neofetch` on Freenode. If you have any ques - Use arrays for `$scrot_program` + ## Args - Fixed bug where `neofetch --config` sourced the user config twice. From 8449bf61f4feaeeae536a8872aa42020721e09e8 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 16 Dec 2016 13:35:39 +1100 Subject: [PATCH 6/6] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aaebb254..1aa85548 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,7 +26,7 @@ Neofetch now has an irc channel at `#neofetch` on Freenode. If you have any ques - A new flag was added called `--gen-man` which generates a neofetch manpage in your current directory. - Delete most of `info()` and instead call `prin()`. - This removes a lot of duplicate code between `info()` and `prin()`. - +- Remove `printf` subshells and instead use `printf -v` to declare the variables. ## Info