@@ -2,10 +2,42 @@
2set -euo pipefail
2set -euo pipefail
4ASSET_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
4ASSET_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
5+REPO_DIR="$ASSET_DIR/.."
6# Ensure submodules are initialized.
7# Ensure submodules are initialized.
8+function update_submodules() {
10+ local submodule_prompt=unspecified
14+ while { read -r submodule && read -r submodule_path; } <&3; do
15+ if ! [[ -d "${REPO_DIR}/.git/modules/${submodule}" ]] && [[ -d "${REPO_DIR}/${submodule_path}" ]]; then
16+ if [[ "$submodule_prompt" = "unspecified" ]]; then
17+ echo "One or more submodules were found to be uninitialized."
18+ printf "Initialize and update them? [Y/n] "
19+ read -r submodule_prompt
22+ case "$submodule_prompt" in
7−git submodule init
24+ git -C "$REPO_DIR" submodule update --init "$submodule_path"
8−git submodule update
25+ };;
30+ echo "Unknown answer. Not updating submodules."
35+ } 3< <(git config --file "${REPO_DIR}/.gitmodules" --null --get-regexp path | xargs -0 printf "%s\n" | sed 's/^submodule.//;s/.path$//')
10# Always remove the local cache to avoid any confusion
42# Always remove the local cache to avoid any confusion
11bat cache --clear
43bat cache --clear