Skip to content

Commit

Permalink
prefer brace-delimiting variables
Browse files Browse the repository at this point in the history
  • Loading branch information
the-mikedavis committed Jan 25, 2022
1 parent 753e1a5 commit fa56b46
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions scripts/grammars
Original file line number Diff line number Diff line change
Expand Up @@ -18,34 +18,34 @@ print_usage_and_exit() {

ensure_grammar_fetched() {
local remote_url="$1"
local grammar_dir="$GRAMMARS_DIR/$(basename $1)"
local grammar_dir="${GRAMMARS_DIR}/$(basename $1)"
# trim trailing whitespace from the revision
local revision="$(echo -e "$2" | tr -d '[:space:]')"

mkdir -p "$grammar_dir"
mkdir -p "${grammar_dir}"

(
cd $grammar_dir
cd "${grammar_dir}"

if [[ ! -d .git ]]; then
git init
fi

local current_remote_url="$(git remote get-url "$REMOTE_NAME" 2>/dev/null || echo -n "")"

if [[ "$current_remote_url" != "$remote_url" ]]; then
git remote set-url "$REMOTE_NAME" "$remote_url" 2>/dev/null || \
git remote add "$REMOTE_NAME" "$remote_url"
if [[ "${current_remote_url}" != "${remote_url}" ]]; then
git remote set-url "${REMOTE_NAME}" "${remote_url}" 2>/dev/null || \
git remote add "${REMOTE_NAME}" "${remote_url}"
fi

local current_revision="$(git rev-parse HEAD 2>/dev/null)"

if [[ "$current_revision" != "$revision" ]]; then
if [[ "${current_revision}" != "${revision}" ]]; then
# shallow clone at exact revision,
# supported in git on the server-side since 2.5.0 (July of 2015), enabled
# on GitHub by default
git fetch "$REMOTE_NAME" "$revision" --depth=1
git checkout "$revision"
git fetch "${REMOTE_NAME}" "${revision}" --depth=1
git checkout "${revision}"
fi
)
}
Expand All @@ -68,8 +68,8 @@ if [[ $# -eq 0 ]]; then
print_usage_and_exit
fi

while ((${#})); do
__opt="${1}"
while (($#)); do
__opt="$1"
shift
case "${__opt}" in
sync)
Expand Down

0 comments on commit fa56b46

Please sign in to comment.