From 508e7c547dacb8b930885fd61057cb8d2868aaf8 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 6 Jun 2015 17:07:10 -0600 Subject: tidy up toru-{info,path} - Quote variables - toru-path: make LASTSYNCFILE and PATHFILE lowercase - toru-path: set IFS when it matters - use `if` instead of && and whatnot - use printf-formatters instead of string interpolation --- src/toru/toru-path | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) (limited to 'src/toru/toru-path') diff --git a/src/toru/toru-path b/src/toru/toru-path index a81ee53..7fc6dfe 100755 --- a/src/toru/toru-path +++ b/src/toru/toru-path @@ -28,39 +28,42 @@ if [ ! -w "$TORUPATH" ]; then exit 1 fi -LASTSYNCFILE=${TORUPATH}/lastsync.paths -PATHFILE=${TORUPATH}/paths.tch +lastsyncfile=${TORUPATH}/lastsync.paths +pathfile=${TORUPATH}/paths.tch -if [ ! -e "${PATHFILE}" ]; then - tcamgr create "${PATHFILE}" +if [ ! -e "${pathfile}" ]; then + tcamgr create "${pathfile}" fi # TODO pass other paths via flags # ABSROOT has trailing slash fullrepos=() +# This loop is complicated because it goes over REPOS backward for (( i = ${#REPOS[@]}-1 ; i >= 0 ; i-- )); do - ${VERBOSE} && msg "Processing [%s]" ${REPOS[$i]} + ${VERBOSE} && msg "Processing [%s]" "${REPOS[$i]}" - [ -d "${ABSROOT}${REPOS[$i]}" ] && \ - fullrepos+=("${ABSROOT}${REPOS[$i]}") + if [ -d "${ABSROOT}${REPOS[$i]}" ]; then + fullrepos+=("${ABSROOT}${REPOS[$i]}") + fi done -pkgbuilds=($(get_pkgbuilds "${LASTSYNCFILE}" "${fullrepos[@]}")) +IFS=$'\n' +pkgbuilds=($(get_pkgbuilds "${lastsyncfile}" "${fullrepos[@]}")) msg "Updating path cache" -msg2 "${#pkgbuilds[@]} PKGBUILDs to update" -for _pkgbuild in ${pkgbuilds[@]}; do - # plain "$_pkgbuild" - load_PKGBUILD "${_pkgbuild}" >/dev/null 2>&1 || { - error "${_pkgbuild} contains errors, skipping" +msg2 "%d PKGBUILDs to update" ${#pkgbuilds[@]} +for _pkgbuild in "${pkgbuilds[@]}"; do + # plain "$_pkgbuild" + if ! load_PKGBUILD "${_pkgbuild}" >/dev/null 2>&1; then + error "%q contains errors, skipping" "${_pkgbuild}" continue - } + fi - fullpath=$(dirname ${_pkgbuild}) + fullpath="$(dirname -- "${_pkgbuild}")" - for _pkg in ${pkgbase} ${pkgname[@]} ${provides[@]}; do - $VERBOSE && msg2 "${_pkg} -> ${fullpath}" - tcamgr put ${PATHFILE} ${_pkg/[<>=]*} ${fullpath} + for _pkg in "${pkgbase}" "${pkgname[@]}" "${provides[@]}"; do + $VERBOSE && msg2 '%s -> %s' "${_pkg}" "${fullpath}" + tcamgr put "${pathfile}" "${_pkg%%[<>=]*}" "${fullpath}" done done -lastsync ${LASTSYNCFILE} +lastsync "${lastsyncfile}" -- cgit v1.2.3-54-g00ecf