Skip to content

Commit a022e3b

Browse files
committed
format
1 parent 3568085 commit a022e3b

File tree

1 file changed

+116
-116
lines changed

1 file changed

+116
-116
lines changed

install.sh

+116-116
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ usage() {
1212
"
1313
fi
1414

15-
cath << EOF
15+
cath <<EOF
1616
Installs Coder.
1717
It tries to use the system package manager if possible.
1818
After successful installation it explains how to start Coder.
@@ -82,7 +82,7 @@ echo_latest_version() {
8282
echo_standalone_postinstall() {
8383
echoh
8484
cath <<EOF
85-
Standalone release has been installed into $STANDALONE_INSTALL_PREFIX/bin/coder
85+
Standalone release has been installed into $STANDALONE_INSTALL_PREFIX/bin/coder
8686
8787
Extend your path to use Coder:
8888
PATH="$STANDALONE_INSTALL_PREFIX/bin:\$PATH"
@@ -133,66 +133,66 @@ main() {
133133
ALL_FLAGS=""
134134
while [ "$#" -gt 0 ]; do
135135
case "$1" in
136-
-*)
137-
ALL_FLAGS="${ALL_FLAGS} $1"
138-
;;
136+
-*)
137+
ALL_FLAGS="${ALL_FLAGS} $1"
138+
;;
139139
esac
140140

141141
case "$1" in
142-
--dry-run)
143-
DRY_RUN=1
144-
;;
145-
--method)
146-
METHOD="$(parse_arg "$@")"
147-
shift
148-
;;
149-
--method=*)
150-
METHOD="$(parse_arg "$@")"
151-
;;
152-
--prefix)
153-
STANDALONE_INSTALL_PREFIX="$(parse_arg "$@")"
154-
shift
155-
;;
156-
--prefix=*)
157-
STANDALONE_INSTALL_PREFIX="$(parse_arg "$@")"
158-
;;
159-
--version)
160-
VERSION="$(parse_arg "$@")"
161-
shift
162-
;;
163-
--version=*)
164-
VERSION="$(parse_arg "$@")"
165-
;;
166-
--edge)
167-
EDGE=1
168-
;;
169-
--rsh)
170-
RSH="$(parse_arg "$@")"
171-
shift
172-
;;
173-
--rsh=*)
174-
RSH="$(parse_arg "$@")"
175-
;;
176-
-h | --h | -help | --help)
177-
usage
178-
exit 0
179-
;;
180-
--)
181-
shift
182-
# We remove the -- added above.
183-
ALL_FLAGS="${ALL_FLAGS% --}"
184-
RSH_ARGS="$*"
185-
break
186-
;;
187-
-*)
188-
echoerr "Unknown flag $1"
189-
echoerr "Run with --help to see usage."
190-
exit 1
191-
;;
192-
*)
193-
RSH_ARGS="$*"
194-
break
195-
;;
142+
--dry-run)
143+
DRY_RUN=1
144+
;;
145+
--method)
146+
METHOD="$(parse_arg "$@")"
147+
shift
148+
;;
149+
--method=*)
150+
METHOD="$(parse_arg "$@")"
151+
;;
152+
--prefix)
153+
STANDALONE_INSTALL_PREFIX="$(parse_arg "$@")"
154+
shift
155+
;;
156+
--prefix=*)
157+
STANDALONE_INSTALL_PREFIX="$(parse_arg "$@")"
158+
;;
159+
--version)
160+
VERSION="$(parse_arg "$@")"
161+
shift
162+
;;
163+
--version=*)
164+
VERSION="$(parse_arg "$@")"
165+
;;
166+
--edge)
167+
EDGE=1
168+
;;
169+
--rsh)
170+
RSH="$(parse_arg "$@")"
171+
shift
172+
;;
173+
--rsh=*)
174+
RSH="$(parse_arg "$@")"
175+
;;
176+
-h | --h | -help | --help)
177+
usage
178+
exit 0
179+
;;
180+
--)
181+
shift
182+
# We remove the -- added above.
183+
ALL_FLAGS="${ALL_FLAGS% --}"
184+
RSH_ARGS="$*"
185+
break
186+
;;
187+
-*)
188+
echoerr "Unknown flag $1"
189+
echoerr "Run with --help to see usage."
190+
exit 1
191+
;;
192+
*)
193+
RSH_ARGS="$*"
194+
break
195+
;;
196196
esac
197197

198198
shift
@@ -241,54 +241,54 @@ main() {
241241
DISTRO=${DISTRO:-$(distro)}
242242

243243
case $DISTRO in
244-
# macOS uses the standalone installation for now.
245-
# Homebrew support is planned. See: https://github.com/coder/coder/issues/1925
246-
macos) install_standalone ;;
247-
# The .deb and .rpm files are pulled from GitHub.
248-
debian) install_deb ;;
249-
fedora | opensuse) install_rpm ;;
250-
# We don't have GitHub releases that work on Alpine or FreeBSD so we have no
251-
# choice but to use npm here.
252-
alpine) install_apk ;;
253-
# For anything else we'll try to install standalone but fall back to npm if
254-
# we don't have releases for the architecture.
255-
*)
256-
echoh "Unsupported package manager."
257-
echoh "Falling back to standalone installation."
258-
install_standalone
259-
;;
244+
# macOS uses the standalone installation for now.
245+
# Homebrew support is planned. See: https://github.com/coder/coder/issues/1925
246+
macos) install_standalone ;;
247+
# The .deb and .rpm files are pulled from GitHub.
248+
debian) install_deb ;;
249+
fedora | opensuse) install_rpm ;;
250+
# We don't have GitHub releases that work on Alpine or FreeBSD so we have no
251+
# choice but to use npm here.
252+
alpine) install_apk ;;
253+
# For anything else we'll try to install standalone but fall back to npm if
254+
# we don't have releases for the architecture.
255+
*)
256+
echoh "Unsupported package manager."
257+
echoh "Falling back to standalone installation."
258+
install_standalone
259+
;;
260260
esac
261261
}
262262

263263
parse_arg() {
264264
case "$1" in
265-
*=*)
266-
# Remove everything after first equal sign.
267-
opt="${1%%=*}"
268-
# Remove everything before first equal sign.
269-
optarg="${1#*=}"
270-
if [ ! "$optarg" ] && [ ! "${OPTIONAL-}" ]; then
271-
echoerr "$opt requires an argument"
272-
echoerr "Run with --help to see usage."
273-
exit 1
274-
fi
275-
echo "$optarg"
276-
return
277-
;;
265+
*=*)
266+
# Remove everything after first equal sign.
267+
opt="${1%%=*}"
268+
# Remove everything before first equal sign.
269+
optarg="${1#*=}"
270+
if [ ! "$optarg" ] && [ ! "${OPTIONAL-}" ]; then
271+
echoerr "$opt requires an argument"
272+
echoerr "Run with --help to see usage."
273+
exit 1
274+
fi
275+
echo "$optarg"
276+
return
277+
;;
278278
esac
279279

280280
case "${2-}" in
281-
"" | -*)
282-
if [ ! "${OPTIONAL-}" ]; then
283-
echoerr "$1 requires an argument"
284-
echoerr "Run with --help to see usage."
285-
exit 1
286-
fi
287-
;;
288-
*)
289-
echo "$2"
290-
return
291-
;;
281+
"" | -*)
282+
if [ ! "${OPTIONAL-}" ]; then
283+
echoerr "$1 requires an argument"
284+
echoerr "Run with --help to see usage."
285+
exit 1
286+
fi
287+
;;
288+
*)
289+
echo "$2"
290+
return
291+
;;
292292
esac
293293
}
294294

@@ -359,7 +359,7 @@ install_standalone() {
359359

360360
# -w only works if the directory exists so try creating it first. If this
361361
# fails we can ignore the error as the -w check will then swap us to sudo.
362-
sh_c mkdir -p "$STANDALONE_INSTALL_PREFIX" 2> /dev/null || true
362+
sh_c mkdir -p "$STANDALONE_INSTALL_PREFIX" 2>/dev/null || true
363363

364364
sh_c="sh_c"
365365
if [ ! -w "$STANDALONE_INSTALL_PREFIX" ]; then
@@ -382,23 +382,23 @@ install_standalone() {
382382
# TODO: fix for Coder v2
383383
has_standalone() {
384384
case $ARCH in
385-
amd64) return 0 ;;
386-
# We only have amd64 for macOS.
387-
arm64)
388-
[ "$(distro)" != darwin ]
389-
return
390-
;;
391-
*) return 1 ;;
385+
amd64) return 0 ;;
386+
# We only have amd64 for macOS.
387+
arm64)
388+
[ "$(distro)" != darwin ]
389+
return
390+
;;
391+
*) return 1 ;;
392392
esac
393393
}
394394

395395
os() {
396396
uname="$(uname)"
397397
case $uname in
398-
Linux) echo linux ;;
399-
Darwin) echo darwin ;;
400-
FreeBSD) echo freebsd ;;
401-
*) echo "$uname" ;;
398+
Linux) echo linux ;;
399+
Darwin) echo darwin ;;
400+
FreeBSD) echo freebsd ;;
401+
*) echo "$uname" ;;
402402
esac
403403
}
404404

@@ -461,15 +461,15 @@ distro_name() {
461461
arch() {
462462
uname_m=$(uname -m)
463463
case $uname_m in
464-
aarch64) echo arm64 ;;
465-
x86_64) echo amd64 ;;
466-
*) echo "$uname_m" ;;
464+
aarch64) echo arm64 ;;
465+
x86_64) echo amd64 ;;
466+
*) echo "$uname_m" ;;
467467
esac
468468
}
469469

470470
command_exists() {
471471
if [ ! "$1" ]; then return 1; fi
472-
command -v "$@" > /dev/null
472+
command -v "$@" >/dev/null
473473
}
474474

475475
sh_c() {
@@ -531,7 +531,7 @@ prefix() {
531531
fifo="$(mktemp -d)/fifo"
532532
mkfifo "$fifo"
533533
sed -e "s#^#$PREFIX: #" "$fifo" &
534-
"$@" > "$fifo" 2>&1
534+
"$@" >"$fifo" 2>&1
535535
}
536536

537537
main "$@"

0 commit comments

Comments
 (0)