X-Git-Url: http://git.tremily.us/?p=dotfiles-framework.git;a=blobdiff_plain;f=dotfiles.sh;h=a1379a33d2d3859c6ce31f777d131e9f93e809c3;hp=907fbe2ffe82c587891c887be2b3b7459e79ff19;hb=41b3be950978aa1012c8c67649ee807761739179;hpb=1249b739f915045ec4f854d073cef5c6fcb7a26e diff --git a/dotfiles.sh b/dotfiles.sh index 907fbe2..a1379a3 100755 --- a/dotfiles.sh +++ b/dotfiles.sh @@ -130,7 +130,7 @@ function list_files() done < <(cd "${DIR}" && find .) } -# Global variable to allow passing associative arrats between functions +# Global variable to allow passing associative arrays between functions if [ "${BASH_MAJOR}" -ge 4 ]; then declare -A REPO_SOURCE_DATA @@ -592,6 +592,9 @@ function link() if [ "${FORCE_LINK}" = 'no' ]; then # don't prompt about --force-link, because this will happen a lot continue # already simlinked + elif [ ! -h "${TARGET}/${FILE}" ]; then + # target file/dir underneath an already symlinked dir + continue else # don't backup links that already point to the right place BACKUP='no' @@ -640,7 +643,7 @@ function disconnect_help() function disconnect() { # multi-repo case handled in main() by run_on_all_repos() - REPO=$(nonempty_option 'link' 'REPO' "${1}") || return 1 + REPO=$(nonempty_option 'disconnect' 'REPO' "${1}") || return 1 maxargs 'disconnect' 1 "${@}" || return 1 DOTFILES_SRC="${DOTFILES_DIR}/${REPO}/patched-src" @@ -705,7 +708,7 @@ function update_help() cat <<-EOF - usage: $0 ${COMMAND} [REPO] + usage: $0 ${COMMAND} [options] [REPO] Where 'REPO' is the name the dotfiles repository to update. If it is not given, all repositories will be updateed. @@ -714,13 +717,21 @@ function update_help() to bring them in sync with the central repositories. Keeps track of the last update time to avoid multiple fetches in the same week. + + ${COMMAND} passes any options it receives through to the link + command. EOF } function update() { + LINK_OPTS='' + while [ "${1::2}" = '--' ]; do + LINK_OPTS="${LINK_FN_OPTS} ${1}" + shift + done # multi-repo case handled in main() by run_on_all_repos() - REPO=$(nonempty_option 'link' 'REPO' "${1}") || return 1 + REPO=$(nonempty_option 'update' 'REPO' "${1}") || return 1 maxargs 'disconnect' 1 "${@}" || return 1 # Update once a week from our remote repository. Mark updates by @@ -733,7 +744,7 @@ function update() "${TOUCH}" "${UPDATE_FILE}" || return 1 fetch "${REPO}" || return 1 patch "${REPO}" || return 1 - link "${REPO}" || return 1 + link ${LINK_OPTS} "${REPO}" || return 1 echo "${REPO} dotfiles updated" fi }