summaryrefslogtreecommitdiff
path: root/.local/bin/config-symlinks
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2015-02-07 00:26:11 -0500
committerLuke Shumaker <lukeshu@sbcglobal.net>2015-02-07 00:26:11 -0500
commit865a768e44624c465e9d42c6ca91d0ef29a8e7ad (patch)
treeb7e960b53a230cd1f9840493a594e1c78c95e290 /.local/bin/config-symlinks
parentf5c41d73b4c085691f2c01dd80366d08cb352a01 (diff)
backport changes from cs-purdue
Diffstat (limited to '.local/bin/config-symlinks')
-rwxr-xr-x.local/bin/config-symlinks9
1 files changed, 7 insertions, 2 deletions
diff --git a/.local/bin/config-symlinks b/.local/bin/config-symlinks
index 0831ca3..7d889f0 100755
--- a/.local/bin/config-symlinks
+++ b/.local/bin/config-symlinks
@@ -1,6 +1,8 @@
#!/bin/bash
-sed -e '/^\s*$/d' -e '/#/d' symlinks | while read _target _link; do
+declare -i ret=0
+
+while read _target _link; do
target="$(sed -rn 's|[^/]+/|../|g;s|/[^/]+$|/|p' <<<"$_link")${_target}"
link="$HOME/$_link"
if [[ -L "$link" ]]; then
@@ -8,8 +10,11 @@ sed -e '/^\s*$/d' -e '/#/d' symlinks | while read _target _link; do
fi
if [[ -e "$link" ]]; then
echo "ERROR: file exists: $link" >> /dev/stderr
+ ret=1
else
mkdir -p "${link%/*}"
ln -s "$target" "$link"
fi
-done
+done < <(sed -e '/^\s*$/d' -e '/#/d' "$XDG_CONFIG_HOME/symlinks")
+
+exit $ret