forked from rwf2/Rocket
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Properly handle paths with spaces in shell scripts.
- Loading branch information
1 parent
b5c2187
commit 2d72928
Showing
4 changed files
with
34 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,19 @@ | ||
#! /usr/bin/env bash | ||
|
||
SCRIPT_PATH=$(cd "$(dirname "$0")" ; pwd -P) | ||
DATABASE_URL=${SCRIPT_PATH}/db/db.sql | ||
DATABASE_URL="${SCRIPT_PATH}/db/db.sql" | ||
|
||
pushd $SCRIPT_PATH > /dev/null | ||
pushd "${SCRIPT_PATH}" > /dev/null | ||
# clear an existing database | ||
rm -f $DATABASE_URL | ||
rm -f "${DATABASE_URL}" | ||
|
||
# install the diesel CLI tools if they're not installed | ||
if ! command -v diesel >/dev/null 2>&1; then | ||
cargo install diesel_cli --no-default-features --features=sqlite > /dev/null | ||
fi | ||
|
||
# create db/db.sql | ||
diesel migration --database-url=$DATABASE_URL run > /dev/null | ||
diesel migration --database-url="${DATABASE_URL}" run > /dev/null | ||
popd > /dev/null | ||
|
||
echo "export DATABASE_URL=$DATABASE_URL" | ||
echo "export DATABASE_URL=\"${DATABASE_URL}\"" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters