From 76c6a9b42a3604d30911c96d5ce4ae3c9be4de97 Mon Sep 17 00:00:00 2001 From: Curtis McEnroe Date: Sat, 27 Jul 2019 17:00:47 -0400 Subject: Shell script style pass --- link.sh | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'link.sh') 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 -- cgit 1.4.1