summary refs log tree commit diff
path: root/link.sh
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2019-07-27 17:00:47 -0400
committerJune McEnroe <june@causal.agency>2019-07-27 17:00:47 -0400
commit76c6a9b42a3604d30911c96d5ce4ae3c9be4de97 (patch)
treea923f81ad039cdacc7b1e29153a5a27ae2d30868 /link.sh
parentAdd c11.pdf (diff)
downloadsrc-76c6a9b42a3604d30911c96d5ce4ae3c9be4de97.tar.gz
src-76c6a9b42a3604d30911c96d5ce4ae3c9be4de97.zip
Shell script style pass
Diffstat (limited to 'link.sh')
-rwxr-xr-xlink.sh24
1 files changed, 12 insertions, 12 deletions
diff --git a/link.sh b/link.sh
index 0f1f49aa..d74f4788 100755
--- a/link.sh
+++ b/link.sh
@@ -1,18 +1,18 @@
 #!/bin/sh
-set -e -u
+set -eu
 
 if [ $# -eq 1 ]; then
-	linkPath=$1
-	filePath="$PWD/home/${linkPath#$HOME/}"
-	[ ! -f "$filePath" ]
-	mkdir -p "$(dirname "$filePath")"
-	mv "$linkPath" "$filePath"
+	link=$1
+	file="${PWD}/home/${link#${HOME}/}"
+	[ ! -f "$file" ]
+	mkdir -p "${file%/*}"
+	mv "$link" "$file"
 fi
 
-find home -type f | while read -r findPath; do
-	filePath="$PWD/$findPath"
-	linkPath="$HOME/${findPath#home/}"
-	mkdir -p "$(dirname "$linkPath")"
-	[ \( -f "$linkPath" -a -L "$linkPath" \) -o ! -f "$linkPath" ]
-	ln -s -f "$filePath" "$linkPath"
+find home -type f | while read -r find; do
+	file="${PWD}/${find}"
+	link="${HOME}/${find#home/}"
+	mkdir -p "${link%/*}"
+	[ \( -f "$link" -a -L "$link" \) -o ! -f "$link" ]
+	ln -fs "$file" "$link"
 done