git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Don't create broken symlinks

From
PRPavel Roskin <proski@gnu.org>
Date
Sep 20, 2005, 15:59 UTC
Message-ID
<1127231995.8374.6.camel@dv>

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.

Signed-off-by: Pavel Roskin <proski@gnu.org>
diff --git a/cmd-rename.sh b/cmd-rename.sh
--- a/cmd-rename.sh
+++ b/cmd-rename.sh
@@ -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
-- 
Regards,
Pavel Roskin
Message 1 of 1 in “Don't create broken symlinks”
  1. Don't create broken symlinksPavel Roskin, Sep 20, 2005

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.