Skip to content

Commit

Permalink
Fix some small bugs in install.sh
Browse files Browse the repository at this point in the history
Fixes bashism in the `args` test in `install.sh` that won't work with POSIX `sh`,
or `bash` in `sh` mode. Since location of `sh` can vary by operating system the
use of `/usr/bin/env` to find the installed `sh` is a safe cross-platform way of
launching this script as described in the `README`.

Modified the pre-installation check to test if the currently installed version
is the same rather than just for the presence of the `atomvm_packbeam`
directory so that upgrading to other versions will be possible with future
releases.

Signed-off-by: Winford <[email protected]>
  • Loading branch information
UncleGrumpy committed Nov 4, 2023
1 parent a7b64ea commit dcaf469
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env sh
#
# This file is part of AtomVM.
#
Expand Down Expand Up @@ -48,7 +48,7 @@ set -e
readonly root_dir="$(cd $(dirname $0) && pwd)"

readonly nargs=$#
if [[ ${nargs} -lt 2 ]]; then
if [ ${nargs} -lt 2 ]; then
echo
echo "Syntax: $0 <prefix> <version>"
echo " where <prefix> is the prefix location for the install"
Expand Down Expand Up @@ -84,8 +84,8 @@ echo_run cp "${src_tar}" "${tmp_dir}/."
echo_run gunzip "${tmp_dir}/atomvm_packbeam-${version}.tar.gz"

readonly dest_dir="${prefix}/atomvm_packbeam"
if [ -e "${dest_dir}" ]; then
echo "ERROR! It looks like ${dest_dir} already exists!"
if [ $(${dest_dir}/bin/packbeam version) = ${version} ]; then
echo "ERROR! It looks like ${version} is already installed!"
exit 1
fi

Expand Down

0 comments on commit dcaf469

Please sign in to comment.