From 0460970a937191ee3ff70658503e7407d4cf6caa Mon Sep 17 00:00:00 2001 From: Curtis McEnroe Date: Thu, 16 Aug 2018 18:00:42 -0400 Subject: Port all scripts to sh Not hard, but having to escape ( ) inside [ ] had me confused for a bit. --- link.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100755 link.sh (limited to 'link.sh') diff --git a/link.sh b/link.sh new file mode 100755 index 00000000..0f1f49aa --- /dev/null +++ b/link.sh @@ -0,0 +1,18 @@ +#!/bin/sh +set -e -u + +if [ $# -eq 1 ]; then + linkPath=$1 + filePath="$PWD/home/${linkPath#$HOME/}" + [ ! -f "$filePath" ] + mkdir -p "$(dirname "$filePath")" + mv "$linkPath" "$filePath" +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" +done -- cgit 1.4.1