Skip to content

Commit

Permalink
Revert: Convert to double brackets
Browse files Browse the repository at this point in the history
Staying POSIX compatible, don't use expanded test syntax from bash
  • Loading branch information
passsy committed Nov 16, 2019
1 parent 0a26003 commit 4e6e2c9
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions flutterw
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
##############################################################################
##
## Flutter start up script for UN*X
## Version: VERSION_PLACEHOLDER
## Date: DATE_PLACEHOLDER
## Version: fix_detached_head_fix
## Date: 2019-11-16 14:54:10
##
## Use this flutter wrapper to bundle Flutter within your project to make
## sure everybody builds with the same version.
Expand All @@ -20,7 +20,7 @@
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [[ -h "$PRG" ]]; do
while [ -h "$PRG" ]; do
ls=$(ls -ld "$PRG")
link=$(expr "$ls" : '.*-> \(.*\)$')
if expr "$link" : '/.*' >/dev/null; then
Expand All @@ -38,26 +38,26 @@ FLUTTER_SUBMODULE_NAME='.flutter'
FLUTTER_DIR="$APP_HOME/$FLUTTER_SUBMODULE_NAME"

# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [[ "$(uname)" = "Darwin" ]] && [[ "$HOME" = "$PWD" ]]; then
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi

# submodule starting with "-" are not initialized
init_status=$(git submodule | grep "\ $FLUTTER_SUBMODULE_NAME$" | cut -c 1)

# Fix not initialized flutter submodule
if [[ "$init_status" = "-" ]]; then
if [ "$init_status" = "-" ]; then
echo "$FLUTTER_SUBMODULE_NAME submodule not initialized. Initializing..."
git submodule update --init ${FLUTTER_SUBMODULE_NAME}
fi

# Detect detach HEAD and fix it. commands like upgrade expect a valid branch, not a detached HEAD
FLUTTER_SYMBOLIC_REF=$(git -C ${FLUTTER_SUBMODULE_NAME} symbolic-ref -q HEAD)
if [[ -z ${FLUTTER_SYMBOLIC_REF} ]]; then
if [ -z ${FLUTTER_SYMBOLIC_REF} ]; then
FLUTTER_REV=$(git -C ${FLUTTER_SUBMODULE_NAME} rev-parse HEAD)
FLUTTER_CHANNEL=$(git config -f .gitmodules submodule.${FLUTTER_SUBMODULE_NAME}.branch)

if [[ -z $FLUTTER_CHANNEL ]]; then
if [ -z $FLUTTER_CHANNEL ]; then
echo "Warning: Submodule '$FLUTTER_SUBMODULE_NAME' doesn't point to an official Flutter channel \
(one of stable|beta|dev|master). './flutterw upgrade' will fail without a channel."
echo "Fix this by adding a specific channel with:"
Expand All @@ -84,7 +84,7 @@ set -e

# Post flutterw tasks. exit code from /bin/flutterw will be used as final exit
FLUTTER_EXIT_STATUS=$?
if [[ ${FLUTTER_EXIT_STATUS} -eq 0 ]]; then
if [ ${FLUTTER_EXIT_STATUS} -eq 0 ]; then

# ./flutterw channel CHANNEL
if echo "$@" | grep -q "channel"; then
Expand Down

0 comments on commit 4e6e2c9

Please sign in to comment.