Skip to content
This repository was archived by the owner on Dec 15, 2023. It is now read-only.

Conversation

@jo2y
Copy link
Contributor

@jo2y jo2y commented Apr 1, 2018

  • Quote bash variable when possible.
  • Fix an undefined $root_dir
  • Remove a redundant rm and let the defined trap handler do it.
  • echo -e is needed when trying to display escape codes.
  • Remove incorrect {{foo}} double curly braces.

- Quote bash variable when possible.
- Fix an undefined $root_dir
- Remove a redundant rm and let the defined trap handler do it.
- echo -e is needed when trying to display escape codes.
- Remove incorrect {{foo}} double curly braces.
@jo2y
Copy link
Contributor Author

jo2y commented Apr 1, 2018

@rogerhub Take a look please. I resisted the urge to change all of the $foo to ${foo} because I'm not sure if there is an official style. I stuck with the majority existing style.

Copy link
Contributor

@rogerhub rogerhub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this!

tmp_dir=$(mktemp -d ${TMPDIR:-/tmp}/war.XXXXXXXX)
trap "{ cd ${root_path}; rm -rf ${tmp_dir}; }" EXIT
cd ${tmp_dir}
root_path="$(pwd)"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think quotes are needed for the right-hand side of assignments. Also, this could be simplified to root_path=$PWD, right?

cd ${tmp_dir}
root_path="$(pwd)"
tmp_dir=$(mktemp -d "${TMPDIR:-/tmp}/war.XXXXXXXX")
trap "{ cd "${root_path}"; rm -rf "${tmp_dir}"; }" EXIT
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these double quotes aren't having their intended effect, since they're nested inside more double quotes. Ideally, this should look like:

cleanup() {
  cd "${root_path}"
  rm -rf "${tmp_dir}"
}
trap cleanup EXIT

That's a tad bit more complicated though, so I'll leave this up to your discretion.

if [ -n "${1-}" ]; then
${APP_ENGINE_ROOT}/bin/appcfg.sh -A "$1" update ${tmp_dir}
retCode=$?
"${APP_ENGINE_ROOT}/bin/appcfg.sh" -A "$1" update "${tmp_dir}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a question: why is -A required in the python version but not here?

trap - EXIT

exit $retCode
exit "$retCode"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optional: ret_code seems more consistent with other variables

tmp_dir="$(mktemp -d "${TMPDIR:-/tmp}/war.XXXXXXXX")"
cp -R "$ROOT" "$tmp_dir"
trap "{ cd "$ROOT"; rm -rf "$tmp_dir"; }}" EXIT
rm -Rf "$tmp_dir/%{workspace_name}/external/com_google_appengine_py"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: lowercase -rf seems more consistent with other usages

if [ -n "${{1-}}" ]; then
has_app_yaml=$(echo ${{@:2}} | grep -E "^([^ ]+ +)*app.yaml")
other_mod_cfgs=$(echo ${{@:2}} | xargs printf "%s\n" | grep -v "^app\.yaml$" | xargs echo)
ROOT="$PWD"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe root_path to match the Java version?

rm -Rf "$tmp_dir/%{workspace_name}/external/com_google_appengine_py"
if [ -n "${1-}" ]; then
has_app_yaml="$(echo "${@:2}" | grep -E "^([^ ]+ +)*app.yaml")"
other_mod_cfgs="$(echo "${@:2}" | xargs printf "%s\n" | grep -v "^app\.yaml$" | xargs echo)"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optional: Some of this code is brittle against paths with spaces in them, but users probably shouldn't be using those anyway. If you really care, there's probably a way to do all this in just bash. Maybe something like:

has_app_yaml=false
other_mod_cfgs=()

for p in "${@:2}"; do
  if [[ "$p" == "app.yaml" ]]; then
    has_app_yaml=true
  else
    modules+=("$p")
  fi
done

And then you can use ${other_mod_cfgs[@]} to pass all of the other .yaml files to appcfg update below.

@jdelfino
Copy link

Hi, is anyone still looking at this? The python .deploy commands are currently broken.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants