Skip to contentSkip to conversation

Don't create broken symlinks

PATCH New Pavel Roskin 1 participant 1 message Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Don't create broken symlinks

cmd-rename.sh creates links for files that are not installed. git-send-email is not installed by default, so git-send-email-script is a broken link.

cmd-rename.sh should only create a link if the link target exists. Also, the patchs add explicit exit codes for failures and ensures exit code 0 if the script is successful.

cmd-rename.sh +7 -3
@@ -1,10 +1,12 @@
 #!/bin/sh
 d="$1"
-test -d "$d" || exit
+test -d "$d" || exit 1
 while read old new
 do
-	rm -f "$d/$old"
-	ln -s "$new" "$d/$old"
+	rm -f "$d/$old" || exit 1
+	if [ -f "$new/$d" ]; then
+		ln -s "$new" "$d/$old"
+	fi
 done <<\EOF
 git-add-script	git-add
 git-archimport-script	git-archimport
@@ -53,3 +55,5 @@ EOF
 # These two are a bit more than symlinks now.
 # git-ssh-push	git-ssh-upload
 # git-ssh-pull	git-ssh-fetch
+
+exit 0
Signature · 2 lines
Regards,
Pavel Roskin