Skip to content

Commit 670b4c3

Browse files
committed
refactor(bash): Using safe printf call
Signed-off-by: Vincent Boutour <[email protected]>
1 parent b51dbae commit 670b4c3

22 files changed

+148
-146
lines changed

init.sh

+21-21
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,21 @@ readonly CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
66
print_title() {
77
local line="--------------------------------------------------------------------------------"
88

9-
printf "%s%s%s\n" "+-" "${line:0:${#1}}" "-+"
10-
printf "%s%s%s\n" "| " "${1}" " |"
11-
printf "%s%s%s\n" "+-" "${line:0:${#1}}" "-+"
9+
printf -- "%s%s%s\n" "+-" "${line:0:${#1}}" "-+"
10+
printf -- "%s%s%s\n" "| " "${1}" " |"
11+
printf -- "%s%s%s\n" "+-" "${line:0:${#1}}" "-+"
1212
}
1313

1414
usage() {
15-
printf "Usage: %s [flags]\n" "${0}"
16-
printf " -a\tRun all stages: symlinks, clean, install and passwords\n"
17-
printf " -c\tClean install and temporary files\n"
18-
printf " -d\tRecreate dotfilesrc\n"
19-
printf " -i\tInstall and configure softwares\n"
20-
printf " -l\tLimiting execution to given filename\n"
21-
printf " -p\tRetrieve and write credentials\n"
22-
printf " -s\tCreate symlinks into \${HOME}\n"
23-
printf " -h\tPrint this help\n"
15+
printf -- "Usage: %s [flags]\n" "${0}"
16+
printf -- " -a\tRun all stages: symlinks, clean, install and passwords\n"
17+
printf -- " -c\tClean install and temporary files\n"
18+
printf -- " -d\tRecreate dotfilesrc\n"
19+
printf -- " -i\tInstall and configure softwares\n"
20+
printf -- " -l\tLimiting execution to given filename\n"
21+
printf -- " -p\tRetrieve and write credentials\n"
22+
printf -- " -s\tCreate symlinks into \${HOME}\n"
23+
printf -- " -h\tPrint this help\n"
2424
}
2525

2626
create_symlinks() {
@@ -56,7 +56,7 @@ do_mandatory_actions() {
5656
}
5757

5858
create_dotfilesrc() {
59-
printf "Select files to install\n"
59+
printf -- "Select files to install\n"
6060

6161
cat >"${HOME}/.dotfilesrc" <<END_OF_DOTFILES_RC
6262
#!/usr/bin/env bash
@@ -68,7 +68,7 @@ END_OF_DOTFILES_RC
6868
BASENAME_FILE="$(basename "${file}")"
6969

7070
local INSTALL_NAME
71-
INSTALL_NAME="$(printf "%s" "${BASENAME_FILE%.sh}" | tr "[:lower:]" "[:upper:]")"
71+
INSTALL_NAME="$(printf -- "%s" "${BASENAME_FILE%.sh}" | tr "[:lower:]" "[:upper:]")"
7272

7373
echo "export DOTFILES_${INSTALL_NAME}=\"true\"" >>"${HOME}/.dotfilesrc"
7474
done < <(find "${CURRENT_DIR}/installations" -not -name "__*" -type f | LC_ALL=C sort | fzf --multi --print0 --preview 'cat {}')
@@ -86,7 +86,7 @@ browse_actions() {
8686
BASENAME_FILE="$(basename "${file}")"
8787

8888
local INSTALL_NAME
89-
INSTALL_NAME="$(printf "%s" "${BASENAME_FILE%.sh}" | tr "[:lower:]" "[:upper:]")"
89+
INSTALL_NAME="$(printf -- "%s" "${BASENAME_FILE%.sh}" | tr "[:lower:]" "[:upper:]")"
9090

9191
if [[ -n ${FILE_LIMIT} ]] && [[ ${INSTALL_NAME} != "${FILE_LIMIT}" ]]; then
9292
continue
@@ -159,20 +159,20 @@ main() {
159159
RUN_SYMLINKS=1
160160
;;
161161
l)
162-
FILE_LIMIT="$(printf "%s" "${OPTARG}" | tr "[:lower:]" "[:upper:]")"
163-
printf "Limiting to %s\n" "${FILE_LIMIT}"
162+
FILE_LIMIT="$(printf -- "%s" "${OPTARG}" | tr "[:lower:]" "[:upper:]")"
163+
printf -- "Limiting to %s\n" "${FILE_LIMIT}"
164164
;;
165165
r)
166-
FILE_LIMIT="$(printf "%s" "${OPTARG}" | tr "[:lower:]" "[:upper:]")"
166+
FILE_LIMIT="$(printf -- "%s" "${OPTARG}" | tr "[:lower:]" "[:upper:]")"
167167
FILE_RESTART=1
168-
printf "Restarting at %s\n" "${FILE_LIMIT}"
168+
printf -- "Restarting at %s\n" "${FILE_LIMIT}"
169169
;;
170170
:)
171-
printf "option -%s requires a value\n" "${OPTARG}" >&2
171+
printf -- "option -%s requires a value\n" "${OPTARG}" >&2
172172
exit 1
173173
;;
174174
\?)
175-
printf "option -%s is invalid\n" "${OPTARG}" >&2
175+
printf -- "option -%s is invalid\n" "${OPTARG}" >&2
176176
usage
177177
exit 2
178178
;;

installations/__default.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ END_OF_BASH_PROFILE
4646
packages_install "${PACKAGES[@]}" "awk"
4747

4848
if [[ $(grep --count "${BREW_PREFIX}" "/etc/shells") -eq 0 ]]; then
49-
printf "+-------------------------+\n"
50-
printf "| changing shell for user |\n"
51-
printf "+-------------------------+\n"
49+
printf -- "+-------------------------+\n"
50+
printf -- "| changing shell for user |\n"
51+
printf -- "+-------------------------+\n"
5252

53-
printf "%s/bin/bash\n" "${BREW_PREFIX}" | sudo tee -a "/etc/shells" >/dev/null
53+
printf -- "%s/bin/bash\n" "${BREW_PREFIX}" | sudo tee -a "/etc/shells" >/dev/null
5454
chsh -s "${BREW_PREFIX}/bin/bash" -u "$(whoami)"
5555
fi
5656
elif command -v apt-get >/dev/null 2>&1; then

installations/dns.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ forward-zone:
8888
sudo unbound-control -c "${UNBOUND_CONF_FILE}" -q reload || true
8989
sudo unbound-control -c "${UNBOUND_CONF_FILE}" -q stop || true
9090

91-
printf "Waiting 1 second before starting unbound...\n"
91+
printf -- "Waiting 1 second before starting unbound...\n"
9292
sleep 1
9393

9494
sudo unbound-control -c "${UNBOUND_CONF_FILE}" -q start
@@ -114,7 +114,7 @@ forward-zone:
114114

115115
if command -v resolvconf >/dev/null 2>&1; then
116116
if [[ -d /etc/NetworkManager/ ]]; then
117-
printf "dns=none\n" | sudo tee "/etc/NetworkManager/NetworkManager.conf" >/dev/null
117+
printf -- "dns=none\n" | sudo tee "/etc/NetworkManager/NetworkManager.conf" >/dev/null
118118
fi
119119

120120
if [[ ${UNBOUND_PORT} -eq 53 ]]; then

installations/sublime.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ install() {
2121
if command -v pacman >/dev/null 2>&1 && [[ $(grep -c "sublime-text" "/etc/pacman.conf") -eq 0 ]]; then
2222
curl --disable --silent --show-error --location --max-time 30 "https://download.sublimetext.com/sublimehq-pub.gpg" | sudo pacman-key --add -
2323
sudo pacman-key --lsign-key "8A8F901A"
24-
printf "\n[sublime-text]\nServer = https://download.sublimetext.com/arch/stable/%s" "${ARCH}" | sudo tee -a "/etc/pacman.conf"
24+
printf -- "\n[sublime-text]\nServer = https://download.sublimetext.com/arch/stable/%s" "${ARCH}" | sudo tee -a "/etc/pacman.conf"
2525
fi
2626

2727
if package_exists "sublime-merge"; then

installations/terraform.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ install() {
1313
terraform_install "${TERRAFORM_VERSION}"
1414

1515
mkdir -p "${HOME}/.terraform.d/plugin-cache"
16-
printf "plugin_cache_dir = \"%s/.terraform.d/plugin-cache\"\ndisable_checkpoint = true\n" "${HOME}" >"${HOME}/.terraformrc"
16+
printf -- "plugin_cache_dir = \"%s/.terraform.d/plugin-cache\"\ndisable_checkpoint = true\n" "${HOME}" >"${HOME}/.terraformrc"
1717

1818
# renovate: datasource=github-releases depName=hashicorp/terraform-ls
1919
local TERRAFORM_LS_VERSION="v0.34.3"
@@ -22,7 +22,7 @@ install() {
2222

2323
credentials() {
2424
if command -v pass >/dev/null 2>&1 && [[ -d ${PASSWORD_STORE_DIR:-${HOME}/.password-store} ]] && [[ $(pass find terraform | wc -l) -gt 1 ]]; then
25-
printf "credentials \"app.terraform.io\" {\n token = \"%s\"\n}" "$(pass_get "dev/terraform" "token")" >>"${HOME}/.terraformrc"
25+
printf -- "credentials \"app.terraform.io\" {\n token = \"%s\"\n}" "$(pass_get "dev/terraform" "token")" >>"${HOME}/.terraformrc"
2626
chmod 600 "${HOME}/.terraformrc"
2727
fi
2828
}

sources/_binary.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ normalized_os() {
8181
OS_NAME="${MACOS_VALUE}"
8282
fi
8383

84-
printf "%s" "${OS_NAME}"
84+
printf -- "%s" "${OS_NAME}"
8585
}
8686

8787
normalized_arch() {
@@ -109,5 +109,5 @@ normalized_arch() {
109109
ARCH="${ARM64_VALUE}"
110110
fi
111111

112-
printf "%s" "${ARCH}"
112+
printf -- "%s" "${ARCH}"
113113
}

sources/_golang.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ if command -v fzf >/dev/null 2>&1; then
2424
return
2525
fi
2626

27-
printf "MODULE=%s\n" "${MODULE_TO_BUMP}"
27+
printf -- "MODULE=%s\n" "${MODULE_TO_BUMP}"
2828
local MODULE_VERSION=""
2929

3030
local GITHUB_TOKEN
@@ -35,7 +35,7 @@ if command -v fzf >/dev/null 2>&1; then
3535

3636
MODULE_VERSION="$(
3737
cat \
38-
<(printf "latest\n") \
38+
<(printf -- "latest\n") \
3939
<(curl --disable --silent --show-error --location --max-time 10 --header "Authorization: token ${GITHUB_TOKEN}" "https://api.github.com/repos/${REPOSITORY_NAME}/branches?per_page=100" | jq --raw-output '.[].name') \
4040
<(curl --disable --silent --show-error --location --max-time 10 --header "Authorization: token ${GITHUB_TOKEN}" "https://api.github.com/repos/${REPOSITORY_NAME}/tags?per_page=100" | jq --raw-output '.[].name') |
4141
fzf --height=20 --ansi --reverse
@@ -45,7 +45,7 @@ if command -v fzf >/dev/null 2>&1; then
4545
fi
4646

4747
if [[ -n ${MODULE_VERSION} ]]; then
48-
printf "MODULE_VERSION=%s\n" "${MODULE_VERSION}"
48+
printf -- "MODULE_VERSION=%s\n" "${MODULE_VERSION}"
4949
MODULE_VERSION="@${MODULE_VERSION}"
5050

5151
var_print_and_run go get -d "${MODULE_TO_BUMP}${MODULE_VERSION}"
@@ -87,7 +87,7 @@ go_mod_local() {
8787
fi
8888

8989
if [[ $(go list -m -json "${MODULE_TO_LOCAL}" | jq --raw-output 'select(.Replace != null) | .Path' | wc -l) -gt 0 ]]; then
90-
printf "Module %s was already replaced, removing it..." "${MODULE_TO_LOCAL}"
90+
printf -- "Module %s was already replaced, removing it..." "${MODULE_TO_LOCAL}"
9191
go mod edit -dropreplace="${MODULE_TO_LOCAL}"
9292
return
9393
fi

sources/_terraform.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ if command -v terraform >/dev/null 2>&1; then
2323
local exit="${?}"
2424

2525
if [[ $(find . -maxdepth 1 -type f -name "*.tf" | wc -l) -gt 0 ]]; then
26-
printf " 🔧 %s" "$(terraform workspace show)"
26+
printf -- " 🔧 %s" "$(terraform workspace show)"
2727
fi
2828

2929
return "${exit}"

sources/aws.sh

+6-6
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ aws_regions() {
44
local ENDPOINTS
55
ENDPOINTS="$(_aws_endpoints)"
66

7-
printf "%s" "${ENDPOINTS}" | jq -r '.partitions[].regions | keys[]'
7+
printf -- "%s" "${ENDPOINTS}" | jq -r '.partitions[].regions | keys[]'
88
}
99

1010
aws_regions_no_service() {
@@ -14,13 +14,13 @@ aws_regions_no_service() {
1414
local SERVICE
1515
SERVICE="$(_aws_regions_service "${1-}")"
1616

17-
if [[ $(printf "%s" "${ENDPOINTS}" | jq -r --arg service "${SERVICE}" '.partitions[].services.[$service] | select(.endpoints != null) | .endpoints | keys[] | select(. == "aws-global") | .' | wc -l) -eq 1 ]]; then
18-
printf "This is an aws-global endpoint\n"
17+
if [[ $(printf -- "%s" "${ENDPOINTS}" | jq -r --arg service "${SERVICE}" '.partitions[].services.[$service] | select(.endpoints != null) | .endpoints | keys[] | select(. == "aws-global") | .' | wc -l) -eq 1 ]]; then
18+
printf -- "This is an aws-global endpoint\n"
1919

2020
return
2121
fi
2222

23-
printf "%s" "${ENDPOINTS}" | jq -r --arg service "${SERVICE}" '[.partitions[].regions | keys[]] - [.partitions[].services.[$service] | select(.endpoints != null) | .endpoints | keys[]]'
23+
printf -- "%s" "${ENDPOINTS}" | jq -r --arg service "${SERVICE}" '[.partitions[].regions | keys[]] - [.partitions[].services.[$service] | select(.endpoints != null) | .endpoints | keys[]]'
2424
}
2525

2626
aws_regions_enpoints() {
@@ -30,13 +30,13 @@ aws_regions_enpoints() {
3030
local SERVICE
3131
SERVICE="$(_aws_regions_service "${1-}")"
3232

33-
printf "%s" "${ENDPOINTS}" | jq -r --arg service "${SERVICE}" '.partitions[].services.[$service] | select(.endpoints != null) | .endpoints'
33+
printf -- "%s" "${ENDPOINTS}" | jq -r --arg service "${SERVICE}" '.partitions[].services.[$service] | select(.endpoints != null) | .endpoints'
3434
}
3535

3636
_aws_endpoints() {
3737
curl --disable --silent --show-error --location --max-time 30 "https://raw.githubusercontent.com/boto/botocore/develop/botocore/data/endpoints.json"
3838
}
3939

4040
_aws_regions_service() {
41-
printf "%s" "${ENDPOINTS}" | jq -r '.partitions[].services | keys[]' | sort -u | fzf --select-1 --query="${1-}"
41+
printf -- "%s" "${ENDPOINTS}" | jq -r '.partitions[].services | keys[]' | sort -u | fzf --select-1 --query="${1-}"
4242
}

sources/clean.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ memory_clean() {
77
sudo sysctl vm.drop_caches=3
88
else
99
sudo sync
10-
printf "3\n" >"/proc/sys/vm/drop_caches"
10+
printf -- "3\n" >"/proc/sys/vm/drop_caches"
1111
fi
1212
}
1313

sources/dev.sh

+22-22
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ qrcode_wifi() {
4646
WIFI_PASSWORD="${WIFI_PASSWORD//;/\\;}"
4747
WIFI_PASSWORD="${WIFI_PASSWORD//:/\\:}"
4848

49-
printf "WIFI:S:%s;T:WPA;P:%s;;" "${WIFI_NAME}" "${WIFI_PASSWORD}" | qrcode
49+
printf -- "WIFI:S:%s;T:WPA;P:%s;;" "${WIFI_NAME}" "${WIFI_PASSWORD}" | qrcode
5050
}
5151

5252
loop() {
@@ -92,8 +92,8 @@ urlencode() {
9292
for ((i = 0; i < length; i++)); do
9393
local c="${1:i:1}"
9494
case "${c}" in
95-
[a-zA-Z0-9.~_-]) printf "%s" "${c}" ;;
96-
' ') printf "%%20" ;;
95+
[a-zA-Z0-9.~_-]) printf -- "%s" "${c}" ;;
96+
' ') printf -- "%%20" ;;
9797
*) printf '%%%02X' "'$c" ;;
9898
esac
9999
done
@@ -124,25 +124,25 @@ stock() {
124124

125125
if [[ ${?} -ne 0 ]]; then
126126
cat "${HEADER_OUPUT}" >/dev/stderr
127-
printf "%s\n" "${YAHOO_OUTPUT}" >/dev/stderr
127+
printf -- "%s\n" "${YAHOO_OUTPUT}" >/dev/stderr
128128
rm -f "${HEADER_OUPUT}"
129129
return 1
130130
fi
131131

132132
rm -f "${HEADER_OUPUT}"
133133

134134
local STOCK_SYMBOL
135-
STOCK_SYMBOL="$(printf "%s" "${YAHOO_OUTPUT}" | jq --raw-output '.chart.result[0].meta | .symbol')"
135+
STOCK_SYMBOL="$(printf -- "%s" "${YAHOO_OUTPUT}" | jq --raw-output '.chart.result[0].meta | .symbol')"
136136

137137
local STOCK_CURRENCY
138-
STOCK_CURRENCY="$(printf "%s" "${YAHOO_OUTPUT}" | jq --raw-output '.chart.result[0].meta | .currency')"
138+
STOCK_CURRENCY="$(printf -- "%s" "${YAHOO_OUTPUT}" | jq --raw-output '.chart.result[0].meta | .currency')"
139139

140140
local EVOLUTION_PERCENT
141141
local OUTPUT_COLOR="${GREEN}"
142142
local EVOLUTION_SIGN=""
143143

144144
_stock_evolution() {
145-
EVOLUTION_PERCENT="$(printf "scale = 4; scale = 4; 100 * ((%s / %s) - 1)" "${CURRENT_PRICE}" "${PREVIOUS_PRICE}" | bc)"
145+
EVOLUTION_PERCENT="$(printf -- "scale = 4; scale = 4; 100 * ((%s / %s) - 1)" "${CURRENT_PRICE}" "${PREVIOUS_PRICE}" | bc)"
146146

147147
OUTPUT_COLOR="${GREEN}"
148148
EVOLUTION_SIGN=""
@@ -155,14 +155,14 @@ stock() {
155155
}
156156

157157
local CURRENT_PRICE
158-
CURRENT_PRICE="$(printf "%s" "${YAHOO_OUTPUT}" | jq --raw-output '.chart.result[0].meta | .regularMarketPrice')"
158+
CURRENT_PRICE="$(printf -- "%s" "${YAHOO_OUTPUT}" | jq --raw-output '.chart.result[0].meta | .regularMarketPrice')"
159159

160160
local PREVIOUS_PRICE
161-
PREVIOUS_PRICE="$(printf "%s" "${YAHOO_OUTPUT}" | jq --raw-output '.chart.result[0].meta | .previousClose')"
161+
PREVIOUS_PRICE="$(printf -- "%s" "${YAHOO_OUTPUT}" | jq --raw-output '.chart.result[0].meta | .previousClose')"
162162

163163
_stock_evolution
164164

165-
printf "%b%s%b %s %s %b%s%s%b\n" "${YELLOW}" "${STOCK_SYMBOL}" "${RESET}" "${CURRENT_PRICE}" "${STOCK_CURRENCY}" "${OUTPUT_COLOR}" "${EVOLUTION_SIGN}" "${EVOLUTION_PERCENT%00}%" "${RESET}"
165+
printf -- "%b%s%b %s %s %b%s%s%b\n" "${YELLOW}" "${STOCK_SYMBOL}" "${RESET}" "${CURRENT_PRICE}" "${STOCK_CURRENCY}" "${OUTPUT_COLOR}" "${EVOLUTION_SIGN}" "${EVOLUTION_PERCENT%00}%" "${RESET}"
166166

167167
if command -v spark >/dev/null 2>&1; then
168168
YAHOO_OUTPUT="$(
@@ -179,26 +179,26 @@ stock() {
179179

180180
if [[ ${?} -ne 0 ]]; then
181181
cat "${HEADER_OUPUT}" >/dev/stderr
182-
printf "%s\n" "${YAHOO_OUTPUT}" >/dev/stderr
182+
printf -- "%s\n" "${YAHOO_OUTPUT}" >/dev/stderr
183183
rm -f "${HEADER_OUPUT}"
184184
return 1
185185
fi
186186

187187
rm -f "${HEADER_OUPUT}"
188188

189-
PREVIOUS_PRICE="$(printf "%s" "${YAHOO_OUTPUT}" | jq --raw-output '.chart.result[0].meta | .chartPreviousClose')"
189+
PREVIOUS_PRICE="$(printf -- "%s" "${YAHOO_OUTPUT}" | jq --raw-output '.chart.result[0].meta | .chartPreviousClose')"
190190
_stock_evolution
191191

192192
printf -- "\n---\n1mo %b%s%s%b\n" "${OUTPUT_COLOR}" "${EVOLUTION_SIGN}" "${EVOLUTION_PERCENT%00}%" "${RESET}"
193-
printf "%s" "${YAHOO_OUTPUT}" | jq -r '.chart.result[0].indicators.quote[0].open | join(",")' | spark
193+
printf -- "%s" "${YAHOO_OUTPUT}" | jq -r '.chart.result[0].indicators.quote[0].open | join(",")' | spark
194194
fi
195195
}
196196

197197
date_in() {
198198
local TZ
199199
TZ="$(rg --files /usr/share/zoneinfo/ | sed 's|/usr/share/zoneinfo/||' | fzf --select-1 --query="${*:-New_York}")"
200200

201-
printf "%b%s%b %b%s%b\n" "${BLUE}" "${TZ}" "${RESET}" "${YELLOW}" "$(TZ=${TZ} date '+%Y-%m-%d %H:%M:%S')" "${RESET}"
201+
printf -- "%b%s%b %b%s%b\n" "${BLUE}" "${TZ}" "${RESET}" "${YELLOW}" "$(TZ=${TZ} date '+%Y-%m-%d %H:%M:%S')" "${RESET}"
202202
}
203203

204204
_fzf_complete_date_in() {
@@ -215,11 +215,11 @@ if [[ ${OSTYPE} =~ ^darwin ]]; then
215215
}
216216

217217
system_state() {
218-
printf "%bThermal%b\n" "${BLUE}" "${RESET}"
218+
printf -- "%bThermal%b\n" "${BLUE}" "${RESET}"
219219
pmset -g therm
220-
printf "%bAC Power adapter%b\n" "${BLUE}" "${RESET}"
220+
printf -- "%bAC Power adapter%b\n" "${BLUE}" "${RESET}"
221221
pmset -g ac
222-
printf "%bBattery%b\n" "${BLUE}" "${RESET}"
222+
printf -- "%bBattery%b\n" "${BLUE}" "${RESET}"
223223
pmset -g batt
224224
}
225225
fi
@@ -233,11 +233,11 @@ rainbow() {
233233
g = (colnum*510/76);
234234
b = (colnum*255/76);
235235
if (g>255) g = 510-g;
236-
printf "\033[48;2;%d;%d;%dm", r,g,b;
237-
printf "\033[38;2;%d;%d;%dm", 255-r,255-g,255-b;
238-
printf "%s\033[0m", substr(s,colnum+1,1);
236+
printf -- "\033[48;2;%d;%d;%dm", r,g,b;
237+
printf -- "\033[38;2;%d;%d;%dm", 255-r,255-g,255-b;
238+
printf -- "%s\033[0m", substr(s,colnum+1,1);
239239
}
240-
printf "\n";
240+
printf -- "\n";
241241
}'
242242
}
243243

@@ -314,7 +314,7 @@ if command -v vegeta >/dev/null 2>&1; then
314314
shift
315315

316316
var_info "Attacking '${URL}' during 30 seconds..."
317-
printf "GET %s" "${URL}" | vegeta attack -duration=30s "${@}" | vegeta plot >vegeta.html && open vegeta.html
317+
printf -- "GET %s" "${URL}" | vegeta attack -duration=30s "${@}" | vegeta plot >vegeta.html && open vegeta.html
318318
sleep 5
319319
rm vegeta.html
320320
}

0 commit comments

Comments
 (0)