@@ -34,27 +34,27 @@ MAGENTA="$(tput setaf 5 2>/dev/null || echo '')"
34
34
NO_COLOR=" $( tput sgr0 2> /dev/null || echo ' ' ) "
35
35
36
36
info () {
37
- printf " ${BOLD}${GREY} >${NO_COLOR} $@ \n "
37
+ printf " %s\n " " ${BOLD}${GREY} >${NO_COLOR} $* "
38
38
}
39
39
40
40
warn () {
41
- printf " ${YELLOW} ! $@ ${NO_COLOR} \n "
41
+ printf " %s\n " " ${YELLOW} ! $* ${NO_COLOR} "
42
42
}
43
43
44
44
error () {
45
- printf " ${RED} x $@ ${NO_COLOR} \n " >&2
45
+ printf " %s\n " " ${RED} x $* ${NO_COLOR} " >&2
46
46
}
47
47
48
48
complete () {
49
- printf " ${GREEN} ✓${NO_COLOR} $@ \n "
49
+ printf " %s\n " " ${GREEN} ✓${NO_COLOR} $* "
50
50
}
51
51
52
- # Gets path to a temporary file, even if
53
- get_tmpfile (){
52
+ # Gets path to a temporary file, even if
53
+ get_tmpfile () {
54
54
local suffix
55
55
suffix=" $1 "
56
56
if hash mktemp; then
57
- printf " $( mktemp) . ${suffix} "
57
+ printf " %s.%s " " $( mktemp) " " ${suffix} "
58
58
else
59
59
# No really good options here--let's pick a default + hope
60
60
printf " /tmp/starship.%s" " ${suffix} "
@@ -63,10 +63,10 @@ get_tmpfile(){
63
63
64
64
# Test if a location is writeable by trying to write to it. Windows does not let
65
65
# you test writeability other than by writing: https://stackoverflow.com/q/1999988
66
- test_writeable (){
66
+ test_writeable () {
67
67
local path
68
68
path=" ${1:- } /test.txt"
69
- if touch " ${path} " 2> /dev/null; then
69
+ if touch " ${path} " 2> /dev/null; then
70
70
rm " ${path} "
71
71
return 0
72
72
else
@@ -107,19 +107,19 @@ fetch() {
107
107
fi
108
108
}
109
109
110
- fetch_and_unpack (){
110
+ fetch_and_unpack () {
111
111
local sudo
112
112
local tmpfile
113
113
sudo=" $1 "
114
114
# I'd like to separate this into a fetch() and unpack() function, but I can't
115
115
# figure out how to get bash functions to read STDIN/STDOUT from pipes
116
116
if [ " ${EXT} " = " tar.gz" ]; then
117
- fetch " ${URL} " | ${sudo} tar xzf${VERBOSE} - -C " ${BIN_DIR} "
117
+ fetch " ${URL} " | ${sudo} tar xzf " ${VERBOSE} " - -C " ${BIN_DIR} "
118
118
elif [ " ${EXT} " = " zip" ]; then
119
119
# According to https://unix.stackexchange.com/q/2690, zip files cannot be read
120
120
# through a pipe. We'll have to do our own file-based setup.
121
121
tmpfile=" $( get_tmpfile " ${EXT} " ) "
122
- fetch " ${URL} " > " ${tmpfile} "
122
+ fetch " ${URL} " > " ${tmpfile} "
123
123
${sudo} unzip " ${tmpfile} " -d " ${BIN_DIR} "
124
124
rm " ${tmpfile} "
125
125
else
@@ -130,9 +130,9 @@ fetch_and_unpack(){
130
130
fi
131
131
}
132
132
133
- elevate_priv (){
133
+ elevate_priv () {
134
134
if ! hash sudo 2> /dev/null; then
135
- error " Could not find the command \ " sudo\ " , needed to get permissions for install."
135
+ error ' Could not find the command "sudo", needed to get permissions for install.'
136
136
info " If you are on Windows, please run your shell as an administrator, then"
137
137
info " rerun this script. Otherwise, please run this script as root, or install"
138
138
info " sudo."
@@ -145,10 +145,10 @@ elevate_priv(){
145
145
}
146
146
147
147
install () {
148
- local msg
149
- local sudo
148
+ local msg
149
+ local sudo
150
150
151
- if test_writeable " ${BIN_DIR} " ; then
151
+ if test_writeable " ${BIN_DIR} " ; then
152
152
sudo=" "
153
153
msg=" Installing Starship, please wait…"
154
154
else
@@ -210,17 +210,17 @@ detect_arch() {
210
210
211
211
confirm () {
212
212
if [ -z " ${FORCE-} " ]; then
213
- printf " ${MAGENTA} ?${NO_COLOR} $@ ${BOLD} [y/N]${NO_COLOR} "
213
+ printf " %s " " ${MAGENTA} ?${NO_COLOR} $* ${BOLD} [y/N]${NO_COLOR} "
214
214
set +e
215
- read -r yn < /dev/tty
215
+ read -r yn < /dev/tty
216
216
rc=$?
217
217
set -e
218
218
if [ $rc -ne 0 ]; then
219
- error " Error reading from prompt (please re-run with the \ ` --yes\ ` option)"
219
+ error ' Error reading from prompt (please re-run with the `--yes` option)'
220
220
exit 1
221
221
fi
222
222
if [ " $yn " != " y" ] && [ " $yn " != " yes" ]; then
223
- error " Aborting (please answer \ " yes\ " to continue)"
223
+ error ' Aborting (please answer "yes" to continue)'
224
224
exit 1
225
225
fi
226
226
fi
@@ -230,14 +230,15 @@ check_bin_dir() {
230
230
local bin_dir=" $1 "
231
231
232
232
if [ ! -d " $BIN_DIR " ]; then
233
- error " Installation location $BIN_DIR does not appear to be a directory"
234
- info " Make sure the location exists and is a directory, then try again."
235
- exit 1
233
+ error " Installation location $BIN_DIR does not appear to be a directory"
234
+ info " Make sure the location exists and is a directory, then try again."
235
+ exit 1
236
236
fi
237
237
238
238
# https://stackoverflow.com/a/11655875
239
239
local good
240
- good=$( IFS=:
240
+ good=$(
241
+ IFS=:
241
242
for path in $PATH ; do
242
243
if [ " ${path} " = " ${bin_dir} " ]; then
243
244
echo 1
271
272
# parse argv variables
272
273
while [ " $# " -gt 0 ]; do
273
274
case " $1 " in
274
- -p|--platform) PLATFORM=" $2 " ; shift 2;;
275
- -b|--bin-dir) BIN_DIR=" $2 " ; shift 2;;
276
- -a|--arch) ARCH=" $2 " ; shift 2;;
277
- -B|--base-url) BASE_URL=" $2 " ; shift 2;;
278
-
279
- -V|--verbose) VERBOSE=1; shift 1;;
280
- -f|-y|--force|--yes) FORCE=1; shift 1;;
281
-
282
- -p=* |--platform=* ) PLATFORM=" ${1#* =} " ; shift 1;;
283
- -b=* |--bin-dir=* ) BIN_DIR=" ${1#* =} " ; shift 1;;
284
- -a=* |--arch=* ) ARCH=" ${1#* =} " ; shift 1;;
285
- -B=* |--base-url=* ) BASE_URL=" ${1#* =} " ; shift 1;;
286
- -V=* |--verbose=* ) VERBOSE=" ${1#* =} " ; shift 1;;
287
- -f=* |-y=* |--force=* |--yes=* ) FORCE=" ${1#* =} " ; shift 1;;
288
-
289
- * ) error " Unknown option: $1 " ; exit 1;;
275
+ -p | --platform)
276
+ PLATFORM=" $2 "
277
+ shift 2
278
+ ;;
279
+ -b | --bin-dir)
280
+ BIN_DIR=" $2 "
281
+ shift 2
282
+ ;;
283
+ -a | --arch)
284
+ ARCH=" $2 "
285
+ shift 2
286
+ ;;
287
+ -B | --base-url)
288
+ BASE_URL=" $2 "
289
+ shift 2
290
+ ;;
291
+
292
+ -V | --verbose)
293
+ VERBOSE=1
294
+ shift 1
295
+ ;;
296
+ -f | -y | --force | --yes)
297
+ FORCE=1
298
+ shift 1
299
+ ;;
300
+
301
+ -p=* | --platform=* )
302
+ PLATFORM=" ${1#* =} "
303
+ shift 1
304
+ ;;
305
+ -b=* | --bin-dir=* )
306
+ BIN_DIR=" ${1#* =} "
307
+ shift 1
308
+ ;;
309
+ -a=* | --arch=* )
310
+ ARCH=" ${1#* =} "
311
+ shift 1
312
+ ;;
313
+ -B=* | --base-url=* )
314
+ BASE_URL=" ${1#* =} "
315
+ shift 1
316
+ ;;
317
+ -V=* | --verbose=* )
318
+ VERBOSE=" ${1#* =} "
319
+ shift 1
320
+ ;;
321
+ -f=* | -y=* | --force=* | --yes=* )
322
+ FORCE=" ${1#* =} "
323
+ shift 1
324
+ ;;
325
+
326
+ * )
327
+ error " Unknown option: $1 "
328
+ exit 1
329
+ ;;
290
330
esac
291
331
done
292
332
@@ -298,7 +338,7 @@ if [ "${ARCH}" = "i386" ]; then
298
338
exit 1
299
339
fi
300
340
301
- printf " ${UNDERLINE} Configuration${NO_COLOR} \n "
341
+ printf " %s\n " " ${UNDERLINE} Configuration${NO_COLOR} "
302
342
info " ${BOLD} Bin directory${NO_COLOR} : ${GREEN}${BIN_DIR}${NO_COLOR} "
303
343
info " ${BOLD} Platform${NO_COLOR} : ${GREEN}${PLATFORM}${NO_COLOR} "
304
344
info " ${BOLD} Arch${NO_COLOR} : ${GREEN}${ARCH}${NO_COLOR} "
0 commit comments