Skip to content

Commit ef20862

Browse files
committed
Fix sandbox.tt variable comparison usage
When an uninitialized variable is given to `-n`, it is treated as not NULL. The variable must be quoted for correct results. `[ -n "$SOLIDUS_BRANCH" ]` It is also recommended for variable comparisons in general as it can produce incorrect results for `! -z`. References: - https://tldp.org/LDP/abs/html/comparison-ops.html - https://tldp.org/LDP/abs/html/comparison-ops.html#STRTEST This meant that before, when running this file with no SOLIDUS_BRANCH variable, $BRANCH would end up NULL and the branch in the Gemfile would be an empty string. This caused an error, whereas instead, it should have defaulted to `master`. Error: ``` fatal: Needed a single revision Git error: command `git rev-parse --verify ''` in directory /Users/ryanwoods/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/cache/bundler/git/solidus-169f1ecb1aee2122950e6d586daf2410f62df66e has failed. Revision does not exist in the repository https://github.com/solidusio/solidus.git. Maybe you misspelled it? If this error persists you could try removing the cache directory '/Users/ryanwoods/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/cache/bundler/git/solidus-169f1ecb1aee2122950e6d586daf2410f62df66e' The git source https://github.com/solidusio/solidus.git is not yet checked out. Please run `bundle install` before trying to start your application ```
1 parent 6270b0b commit ef20862

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

  • lib/solidus_dev_support/templates/extension/bin

lib/solidus_dev_support/templates/extension/bin/sandbox.tt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env bash
22

33
set -e
4-
if [ ! -z $DEBUG ]
4+
if [ ! -z "$DEBUG" ]
55
then
66
set -x
77
fi
@@ -28,7 +28,7 @@ sqlite3|sqlite)
2828
esac
2929
echo "~~> Using $RAILSDB as the database engine"
3030

31-
if [ -n $SOLIDUS_BRANCH ]
31+
if [ -n "$SOLIDUS_BRANCH" ]
3232
then
3333
BRANCH=$SOLIDUS_BRANCH
3434
else
@@ -37,7 +37,7 @@ else
3737
fi
3838
echo "~~> Using branch $BRANCH of solidus"
3939

40-
if [ -z $SOLIDUS_FRONTEND ]
40+
if [ -z "$SOLIDUS_FRONTEND" ]
4141
then
4242
echo "~~> Use 'export SOLIDUS_FRONTEND=[solidus_frontend|solidus_starter_frontend]' to control the Solidus frontend"
4343
SOLIDUS_FRONTEND="solidus_frontend"

0 commit comments

Comments
 (0)