X-Git-Url: https://plomlompom.com/repos/foo.html?a=blobdiff_plain;f=all_new_2018%2Fsymlink_etc.sh;h=90cb20ab51cfdb6d07c9d8e295d3c361eea89f24;hb=12aea3ecd6036c77cbc9ea360d8cad116b61573f;hp=238d136123d2bbf92d74b432a27a0d620fbb5f3f;hpb=753f7f64a8295dac2ab15cf227396529441870a5;p=config diff --git a/all_new_2018/symlink_etc.sh b/all_new_2018/symlink_etc.sh old mode 100644 new mode 100755 index 238d136..90cb20a --- a/all_new_2018/symlink_etc.sh +++ b/all_new_2018/symlink_etc.sh @@ -1,14 +1,20 @@ #!/bin/sh -# Symbolically link files to those under linkable_etc_files/$1/, e.g. -# link /etc/foo/bar to linkable_etc_files/$1/etc/foo/bar. Create -# directories as necessary. +# Symbolically link files to those in argument-selected subdirectories +# of linkable_etc_files//, e.g. link /etc/foo/bar to +# linkable_etc_files/$1/etc/foo/bar and so on. Create directories as +# necessary. # CAUTION: This removes original files at the affected paths. set -e -target="$1" -config_tree_prefix="~/config/all_new_2018/linkable_etc_files/" -cd "$config_tree_prefix""$target" -for path in $(find .); do - dest=$(echo "$path" | cut -c2-) - ln -fs "$path" "$dest" +config_tree_prefix="${HOME}/config/all_new_2018/linkable_etc_files/" + +for target in "$@"; do + cd "${config_tree_prefix}${target}" + for path in $(find . -type f); do + linking=$(echo "${path}" | cut -c2-) + linked=$(realpath "${path}") + dir=$(dirname "${linking}") + mkdir -p "${dir}" + ln -fs "${linked}" "${linking}" + done done