From 4b0923c0e73aa08f8ac57a017051804fa1d35148 Mon Sep 17 00:00:00 2001 From: "T. Joseph Carter" Date: Fri, 6 Feb 2015 05:30:53 -0800 Subject: [PATCH] Reduce variable expansions in libretro-fetch.sh --- libretro-fetch.sh | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/libretro-fetch.sh b/libretro-fetch.sh index 1caf84a7..3e10e2df 100755 --- a/libretro-fetch.sh +++ b/libretro-fetch.sh @@ -44,16 +44,17 @@ log_verbose() { # fetch_git # Clones or pulls updates from a git repository into a local directory fetch_git() { + fetch_dir="${WORKDIR}/${2}" if [ -n "${3}" ]; then echo "=== Fetching ${3} ===" fi - if [ -d "${WORKDIR}/${2}/.git" ]; then - log_verbose "${WORKDIR}/${2}:git pull" - cd "${WORKDIR}/${2}" + if [ -d "${fetch_dir}/.git" ]; then + log_verbose "${fetch_dir}:git pull" + cd "${fetch_dir}" git pull else - log_verbose "git clone \"${1}\" \"${WORKDIR}/${2}\"" - git clone "${1}" "${WORKDIR}/${2}" + log_verbose "git clone \"${1}\" \"${fetch_dir}\"" + git clone "${1}" "${fetch_dir}" fi if [ -n "${3}" ]; then echo "=== Fetched ===" @@ -64,20 +65,21 @@ fetch_git() { # Clones or pulls updates from a git repository (and its submodules, if any) # into a local directory fetch_git_submodules() { + fetch_dir="${WORKDIR}/${2}" if [ -n "${3}" ]; then echo "=== Fetching ${3} ===" fi - if [ -d "${WORKDIR}/${2}/.git" ]; then - cd "${WORKDIR}/${2}" - log_verbose "${WORKDIR}/${2}:git pull" + if [ -d "${fetch_dir}/.git" ]; then + cd "${fetch_dir}" + log_verbose "${fetch_dir}:git pull" git pull - log_verbose "${WORKDIR}/${2}:git submodule foreach git pull origin master" + log_verbose "${fetch_dir}:git submodule foreach git pull origin master" git submodule foreach git pull origin master else - log_verbose "git clone \"${1}\" \"${WORKDIR}/${2}\"" - git clone "${1}" "${WORKDIR}/${2}" - cd "${WORKDIR}/${2}" - log_verbose "${WORKDIR}/${2}:git submodule update --init" + log_verbose "git clone \"${1}\" \"${fetch_dir}\"" + git clone "${1}" "${fetch_dir}" + cd "${fetch_dir}" + log_verbose "${fetch_dir}:git submodule update --init" git submodule update --init fi if [ -n "${3}" ]; then @@ -92,18 +94,19 @@ fetch_git_submodules() { # Basically if the core has a ton of external dependencies, you may not want # them updated automatically fetch_git_submodules_no_update() { + fetch_dir="${WORKDIR}/${2}" if [ -n "${3}" ]; then echo "=== Fetching ${3} ===" fi - if [ -d "${WORKDIR}/${2}/.git" ]; then - cd "${WORKDIR}/${2}" - log_verbose "${WORKDIR}/${2}:git pull" + if [ -d "${fetch_dir}/.git" ]; then + cd "${fetch_dir}" + log_verbose "${fetch_dir}:git pull" git pull else - log_verbose "git clone \"${1}\" \"${WORKDIR}/${2}\"" - git clone "${1}" "${WORKDIR}/${2}" - cd "${WORKDIR}/${2}" - log_verbose "${WORKDIR}/${2}:git submodule update --init" + log_verbose "git clone \"${1}\" \"${fetch_dir}\"" + git clone "${1}" "${fetch_dir}" + cd "${fetch_dir}" + log_verbose "${fetch_dir}:git submodule update --init" git submodule update --init fi if [ -n "${3}" ]; then