summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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