@@ -4,15 +4,24 @@ set -o errexit
44
55MONGOSH_RELEASES_URL=https://downloads.mongodb.com/compass/mongosh.json
66
7+ say () {
8+ echo >&2 " $@ "
9+ }
10+
11+ sayf () {
12+ # shellcheck disable=SC2059
13+ printf >&2 " $@ "
14+ }
15+
716show_download_link () {
8- echo >&2 " Download mongosh manually from:"
9- echo >&2
10- printf >&2 " \t%s\n" , ' https://www.mongodb.com/try/download/shell'
17+ say " Download mongosh manually from:"
18+ say
19+ sayf " \t%s\n" ' https://www.mongodb.com/try/download/shell'
1120}
1221
1322for tool in jq curl; do
1423 which " $tool " > /dev/null || {
15- echo >&2 " This script requires '$tool '."
24+ say " This script requires '$tool '."
1625 exit 1
1726 }
1827done
@@ -29,7 +38,7 @@ case "$os" in
2938 ext=zip
3039 ;;
3140 * )
32- echo >&2 " ❌ This script does not support this OS ($os )."
41+ say " ❌ This script does not support this OS ($os )."
3342 show_download_link
3443
3544 exit 1
6170url=$( curl -fsSL $MONGOSH_RELEASES_URL | jq -r " $jq_query " )
6271
6372if [ -z " $url " ]; then
64- echo >&2 " ❓ No download found for $os on $arch ."
73+ say " ❓ No download found for $os on $arch ."
6574 show_download_link
6675 exit 1
6776fi
@@ -70,16 +79,16 @@ case "$ext" in
7079 zip)
7180 file=$( mktemp)
7281
73- echo " Downloading $url to $file …"
82+ say " Downloading $url to $file …"
7483 trap ' rm -f "$file"' EXIT
7584
7685 curl -fsSL " $url " > " $file "
77- echo " Downloaded $ext file; extracting mongosh …"
86+ say " Downloaded $ext file; extracting mongosh …"
7887
7988 unzip -vj " $file " ' */bin/mongosh*'
8089 ;;
8190 tgz)
82- echo " Downloading & extracting from $url …"
91+ say " Downloading & extracting from $url …"
8392
8493 curl -fsSL " $url " | tar -xzf - \
8594 --transform " s/.*\///" \
@@ -88,9 +97,9 @@ case "$ext" in
8897
8998 ;;
9099 * )
91- echo >&2 " Bad file extension: $ext "
100+ say " Bad file extension: $ext "
92101 show_download_link
93102 exit 1
94103esac
95104
96- echo " ✅ Success! 'mongosh' and its crypto library are now saved in this directory."
105+ say " ✅ Success! 'mongosh' and its crypto library are now saved in this directory."
0 commit comments