on master help sign in
Reformat info.sh
116d76aEthan P
diagnostics/info.sh+20−22
@@ -7,7 +7,6 @@ set -o pipefail
7export LC_ALL=C
7export LC_ALL=C
8export LANG=C
8export LANG=C
9
9
10−
11# -----------------------------------------------------------------------------
10# -----------------------------------------------------------------------------
12# Modules:
11# Modules:
13# -----------------------------------------------------------------------------
12# -----------------------------------------------------------------------------
@@ -59,12 +58,12 @@ _bat_:run() {
59
58
60_bat_config_:run() {
59_bat_config_:run() {
61 if [[ -f "$(bat --config-file)" ]]; then
60 if [[ -f "$(bat --config-file)" ]]; then
62− _out_fence cat "$(bat --config-file)";
61+ _out_fence cat "$(bat --config-file)"
63 fi
62 fi
64}
63}
65
64
66_bat_wrapper_:run() {
65_bat_wrapper_:run() {
67− if file "$(which bat)" | grep "text executable" &>/dev/null; then
66+ if file "$(which bat)" | grep "text executable" &> /dev/null; then
68 _out_fence cat "$(which bat)"
67 _out_fence cat "$(which bat)"
69 return
68 return
70 fi
69 fi
@@ -74,20 +73,23 @@ _bat_wrapper_:run() {
74_bat_wrapper_function_:run() {
73_bat_wrapper_function_:run() {
75 case "$("$SHELL" --version | head -n 1)" in
74 case "$("$SHELL" --version | head -n 1)" in
76 *fish*)
75 *fish*)
77− if "$SHELL" --login -i -c 'type bat' 2>&1 | grep 'function' &>/dev/null; then
76+ if "$SHELL" --login -i -c 'type bat' 2>&1 | grep 'function' &> /dev/null; then
78 _out_fence "$SHELL" --login -c 'functions bat'
77 _out_fence "$SHELL" --login -c 'functions bat'
79 return
78 return
80− fi ;;
79+ fi
80+ ;;
81
81
82− *bash*|*zsh*)
82+ *bash* | *zsh*)
83− if "$SHELL" --login -i -c 'type bat' 2>&1 | grep 'function' &>/dev/null; then
83+ if "$SHELL" --login -i -c 'type bat' 2>&1 | grep 'function' &> /dev/null; then
84 _out_fence "$SHELL" --login -c 'declare -f bat'
84 _out_fence "$SHELL" --login -c 'declare -f bat'
85 return
85 return
86− fi ;;
86+ fi
87+ ;;
87
88
88 *)
89 *)
89 echo "Unable to determine if a wrapper function is set."
90 echo "Unable to determine if a wrapper function is set."
90− return ;;
91+ return
92+ ;;
91 esac
93 esac
92 printf "\nNo wrapper function.\n"
94 printf "\nNo wrapper function.\n"
93}
95}
@@ -95,15 +97,14 @@ _bat_wrapper_function_:run() {
95_system_:run() {
97_system_:run() {
96 _out uname -srm
98 _out uname -srm
97
99
98− if command -v "sw_vers" &>/dev/null; then _out sw_vers; fi
100+ if command -v "sw_vers" &> /dev/null; then _out sw_vers; fi
99− if command -v "lsb_release" &>/dev/null; then _out lsb_release -a; fi
101+ if command -v "lsb_release" &> /dev/null; then _out lsb_release -a; fi
100}
102}
101
103
102_tool_:run() {
104_tool_:run() {
103 _out less --version | head -n1
105 _out less --version | head -n1
104}
106}
105
107
106−
107# -----------------------------------------------------------------------------
108# -----------------------------------------------------------------------------
108# Functions:
109# Functions:
109# -----------------------------------------------------------------------------
110# -----------------------------------------------------------------------------
@@ -127,7 +128,7 @@ _out_fence() {
127}
128}
128
129
129_tput() {
130_tput() {
130− tput "$@" 1>&2 2>/dev/null
131+ tput "$@" 1>&2 2> /dev/null
131}
132}
132
133
133_collects() {
134_collects() {
@@ -138,7 +139,7 @@ _ask_module() {
138 _tput clear
139 _tput clear
139 _tput cup 0 0
140 _tput cup 0 0
140
141
141−cat 1>&2 <<EOF
142+ cat 1>&2 << EOF
142--------------------------------------------------------------------------------
143--------------------------------------------------------------------------------
143This script runs some harmless commands to collect information about your
144This script runs some harmless commands to collect information about your
144system and bat configuration. It will give you a small preview of the commands
145system and bat configuration. It will give you a small preview of the commands
@@ -167,13 +168,13 @@ EOF
167 printf "\n" 1>&2
168 printf "\n" 1>&2
168 local response
169 local response
169 while true; do
170 while true; do
170− _tput cup "$(( $(tput lines || echo 22) - 2 ))"
171+ _tput cup "$(($( tput lines || echo 22) - 2))"
171 _tput el
172 _tput el
172 read -er -p "Collect $(sed 's/_/ /' <<< "$1") data? [Y/n] " response
173 read -er -p "Collect $(sed 's/_/ /' <<< "$1") data? [Y/n] " response
173 case "$response" in
174 case "$response" in
174− Y|y|yes|'') return 0 ;;
175+ Y | y | yes | '') return 0 ;;
175− N|n|no) return 1 ;;
176+ N | n | no) return 1 ;;
176− *) continue
177+ *) continue ;;
177 esac
178 esac
178 done
179 done
179}
180}
@@ -184,13 +185,12 @@ _run_module() {
184 "_$1_:run"
185 "_$1_:run"
185}
186}
186
187
187−
188# -----------------------------------------------------------------------------
188# -----------------------------------------------------------------------------
189# Functions:
189# Functions:
190# -----------------------------------------------------------------------------
190# -----------------------------------------------------------------------------
191
191
192# Ask for consent.
192# Ask for consent.
193−if [[ "$1" = '-y' ]]; then
193+if [[ "$1" == '-y' ]]; then
194 _modules_consented=("${_modules[@]}")
194 _modules_consented=("${_modules[@]}")
195else
195else
196 trap '_tput rmcup; exit 1' INT
196 trap '_tput rmcup; exit 1' INT
@@ -208,5 +208,3 @@ for _module in "${_modules_consented[@]}"; do
208 _run_module "$_module" 2>&1
208 _run_module "$_module" 2>&1
209 printf "\n"
209 printf "\n"
210done
210done
211−
212−