2 # When invoked with an absolute path name as an argument, redo-whichdo
3 # must output non-existent dofiles in the same directory until it
4 # outputs one that exists.
6 dofiles="default.do default.c.do default.b.c.do a.b.c.do"
8 for dofile in ${dofiles}; do
9 if test -e "${dofile}"; then
14 for dofile in ${dofiles}; do
15 >"${dofile}" cat <<EOF
20 redo-whichdo "${PWD}/a.b.c" \
24 whichdo_dofiles_nonexistent=$(
25 printf '%s\n' "${whichdo_dofiles}" \
26 |sed '$d' # BusyBox v.1.19.3 has no “head -n-1”
28 for whichdo_dofile_nonexistent in ${whichdo_dofiles_nonexistent}; do
29 if test -e "${whichdo_dofile_nonexistent}"; then
30 >&2 printf 'redo-whichdo prints %s as nonexistent dofile, but it exists.\n' \
31 "${whichdo_dofile_nonexistent}"
36 whichdo_dofile_existent=$(
37 printf '%s\n' "${whichdo_dofiles}" \
40 if ! test -e "${whichdo_dofile_existent}"; then
41 >&2 printf 'redo-whichdo prints %s as existent dofile, but it does not exist.\n' \
42 "${whichdo_dofile_existent}"