I have this script:
#!/usr/bin/env sh
# note: we must use sh instead of bash, it's more cross-platform
set -e;
if [[ "$skip_postinstall" == "yes" ]]; then # TODO rename 'skip_postinstall' to something more specific
echo "skipping postinstall routine.";
exit 0;
fi
export FORCE_COLOR=1;
export skip_postinstall="yes"; # TODO rename 'skip_postinstall' to something more specific
mkdir -p "$HOME/.oresoftware/bin" || {
echo "Could not create .oresoftware dir in user home.";
exit 1;
}
(
echo 'Installing run-tsc-if on your system.';
curl -H 'Cache-Control: no-cache' -s -S -o- 'https://raw.githubusercontent.com/oresoftware/run-tsc-if/master/install.sh' | bash || {
echo 'Could not install run-tsc-if on your system. That is a problem.';
exit 1;
}
) 2> /dev/null
if [[ "$(uname -s)" != "Darwin" ]]; then
exit 0;
fi
if [[ ! -f "$HOME/.oresoftware/bin/realpath" ]]; then
(
curl --silent -o- 'https://raw.githubusercontent.com/oresoftware/realpath/master/assets/install.sh' | bash || {
echo "Could not install realpath on your system.";
exit 1;
}
)
fi
# the end of the postinstall script
when I run it I get:
./assets/postinstall.sh: 7: ./assets/postinstall.sh: [[: not found
Installing run-tsc-if on your system.
=> Installing 'run-tsc-if' on your system.
=> run-tsc-if download/installation succeeded.
./assets/postinstall.sh: 29: ./assets/postinstall.sh: [[: not found
./assets/postinstall.sh: 33: ./assets/postinstall.sh: [[: not found
but if I replace the double [[ brackets with single brackets, I get:
./postinstall.sh: 7: [: unexpected operator
which just comes from:
if [ "$skip_postinstall" == "yes" ]; then
echo "skipping postinstall routine.";
exit 0;
fi
umm what do I do? I tried using test
instead of [
and [[
and that didn't work either.
[[
s into http://shellcheck.net and note the error messages. Now replace the[[
s by[
s. You'll find it pretty clear what and where the problem is and you can click on the error codes for more info :-). – Ed Morton Feb 24 '20 at 23:50