#!/bin/bash
set -Eeuo pipefail

readonly is_snapshot=${is_snapshot:?"true or false"}
marketing_version=${marketing_version:-""}

main() {
  if [[ "${is_snapshot}" == false && -z "${marketing_version}" ]]; then
    echo "When no snapshot, you have to set 'marketing_version', eg 0.38.1"
    exit 1
  fi

  echo "### Setting versions of VimR"
  pushd "$(dirname "${BASH_SOURCE[0]}")/.." >/dev/null

    local bundle_version
    bundle_version="$(date "+%Y%m%d.%H%M%S")"
    readonly bundle_version

    if [[ "${is_snapshot}" == true ]]; then
        marketing_version="SNAPSHOT-${bundle_version}"
    fi
    readonly marketing_version

    pushd VimR >/dev/null
      agvtool new-version -all "${bundle_version}"
      agvtool new-marketing-version "${marketing_version}"
    popd >/dev/null

  popd >/dev/null
  echo "### Set versions of VimR"
}

main

#!/bin/bash
set -Eeuo pipefail

echo "### Setting versions of VimR"
pushd "$( dirname "${BASH_SOURCE[0]}" )/.." > /dev/null

readonly is_snapshot=${is_snapshot:?"true or false"}
marketing_version=${marketing_version:?"0.29.0"}

pushd VimR > /dev/null
    # bundle version
    agvtool bump -all
    readonly bundle_version=$(agvtool what-version | sed '2q;d' | sed -E 's/ +(.+)/\1/')

    # marketing version
    if [[ ${is_snapshot} == true ]]; then
        marketing_version="SNAPSHOT-${bundle_version}"
    fi

    agvtool new-marketing-version ${marketing_version}
popd > /dev/null

for proj in 'NvimView'; do
    pushd ${proj}
    agvtool new-version -all ${bundle_version}
    agvtool new-marketing-version ${marketing_version}
    popd
done

popd > /dev/null
echo "### Set versions of VimR"

--- 
+++ 
@@ -1,34 +1,31 @@
 #!/bin/bash
 set -Eeuo pipefail
 
+echo "### Setting versions of VimR"
+pushd "$( dirname "${BASH_SOURCE[0]}" )/.." > /dev/null
+
 readonly is_snapshot=${is_snapshot:?"true or false"}
-marketing_version=${marketing_version:-""}
+marketing_version=${marketing_version:?"0.29.0"}
 
-main() {
-  if [[ "${is_snapshot}" == false && -z "${marketing_version}" ]]; then
-    echo "When no snapshot, you have to set 'marketing_version', eg 0.38.1"
-    exit 1
-  fi
+pushd VimR > /dev/null
+    # bundle version
+    agvtool bump -all
+    readonly bundle_version=$(agvtool what-version | sed '2q;d' | sed -E 's/ +(.+)/\1/')
 
-  echo "### Setting versions of VimR"
-  pushd "$(dirname "${BASH_SOURCE[0]}")/.." >/dev/null
-
-    local bundle_version
-    bundle_version="$(date "+%Y%m%d.%H%M%S")"
-    readonly bundle_version
-
-    if [[ "${is_snapshot}" == true ]]; then
+    # marketing version
+    if [[ ${is_snapshot} == true ]]; then
         marketing_version="SNAPSHOT-${bundle_version}"
     fi
-    readonly marketing_version
 
-    pushd VimR >/dev/null
-      agvtool new-version -all "${bundle_version}"
-      agvtool new-marketing-version "${marketing_version}"
-    popd >/dev/null
+    agvtool new-marketing-version ${marketing_version}
+popd > /dev/null
 
-  popd >/dev/null
-  echo "### Set versions of VimR"
-}
+for proj in 'NvimView'; do
+    pushd ${proj}
+    agvtool new-version -all ${bundle_version}
+    agvtool new-marketing-version ${marketing_version}
+    popd
+done
 
-main
+popd > /dev/null
+echo "### Set versions of VimR"
Use date as bundle version
