#!/bin/sh set -eu INDEX="$1" PROJECTS="$(cut -d':' -f1 "$INDEX")" COMMANDS="tidy get build test up" TAB=$(printf "\t") escape_dir() { echo "$1" | sed -e 's|/|\\/|g' -e 's|\.|\\.|g' } expand() { local prefix="$1" suffix="$2" local x= out= shift 2 for x; do out="${out:+$out }${prefix}$x${suffix}" done echo "$out" } prefixed() { local prefix="${1:+$1-}" shift expand "$prefix" "" "$@" } suffixed() { local suffix="${1:+-$1}" shift expand "" "$suffix" "$@" } # packed remove excess whitespace from lines of commands packed() { sed -e 's/^[ \t]\+//' -e 's/[ \t]\+$//' -e '/^$/d;' -e '/^#/d'; } # packet_oneline converts a multiline script into packed single-line equivalent packed_oneline() { packed | tr '\n' ';' | sed -e 's|;$||' -e 's|then;|then |g' -e 's|;[ \t]*|; |g' } gen_revive_exclude() { local self="$1" local dirs= d= dirs="$(cut -d: -f2 "$INDEX" | grep -v '^.$' || true)" if [ "." != "$self" ]; then dirs=$(echo "$dirs" | sed -n -e "s;^$self/\(.*\)$;\1;p") fi for d in $dirs; do printf -- "-exclude ./$d/... " done } gen_var_name() { local x= for x; do echo "$x" | tr 'a-z-' 'A-Z_' done } # generate files lists # gen_files_lists() { local name= dir= mod= deps= local files= files_cmd= local filter= out_pat= cat <