# usage: nonempty_option LOC NAME VALUE
function nonempty_option()
{
- LOC="${1}"
- NAME="${2}"
- VALUE="${3}"
- if [ -z "${VALUE}" ]; then
- echo "ERROR: empty value for ${NAME} in ${LOC}" >&2
- return 1
- fi
- echo "${VALUE}"
+ LOC="${1}"
+ NAME="${2}"
+ VALUE="${3}"
+ if [ -z "${VALUE}" ]; then
+ echo "ERROR: empty value for ${NAME} in ${LOC}" >&2
+ return 1
+ fi
+ echo "${VALUE}"
}
# usage: maxargs LOC MAX "${@}"
COMMAND="${1}"
if [ -z "${REPO}" ]; then # run on all repositories
for REPO in *; do
- if [ "${REPO}" = '*' ]; then
- break # no known repositories
- fi
- "${COMMAND}" "${REPO}" || return 1
+ if [ "${REPO}" = '*' ]; then
+ break # no known repositories
+ fi
+ "${COMMAND}" "${REPO}" || return 1
done
return
fi
BACKUP='yes'
while [ "${1::2}" = '--' ]; do
case "${1}" in
- '--force')
- FORCE='yes'
+ '--force')
+ FORCE='yes'
+ ;;
+ '--force-file')
+ FORCE='file'
;;
- '--force-file')
- FORCE='file'
+ '--dry-run')
+ DRY_RUN='yes'
+ ;;
+ '--no-backup')
+ BACKUP='no'
;;
- '--dry-run')
- DRY_RUN='yes'
- ;;
- '--no-backup')
- BACKUP='no'
- ;;
*)
echo "ERROR: invalid option to link (${1})" >&2
return 1
COMMAND=''
while [ "${1::2}" = '--' ]; do
case "${1}" in
- '--help')
- main_help || return 1
- return
- ;;
- '--version')
- echo "${VERSION}"
- return
- ;;
+ '--help')
+ main_help || return 1
+ return
+ ;;
+ '--version')
+ echo "${VERSION}"
+ return
+ ;;
'--dotfiles-dir')
DOTFILES_DIR="${2}"
- shift
+ shift
;;
'--target')
TARGET="${2}"
- shift
+ shift
;;
*)
echo "ERROR: invalid option to ${0} (${1})" >&2
"${COMMAND}_help" || return 1
elif [ "${COMMAND}" = 'clone' ]; then
"${COMMAND}" "${@}" || return 1
- else
+ else
OPTIONS=()
while [ "${1::2}" = '--' ]; do
OPTIONS+=("${1}")