summaryrefslogtreecommitdiff
path: root/Master/tlpkg/bin/deref-symlinks
diff options
context:
space:
mode:
Diffstat (limited to 'Master/tlpkg/bin/deref-symlinks')
-rwxr-xr-xMaster/tlpkg/bin/deref-symlinks22
1 files changed, 22 insertions, 0 deletions
diff --git a/Master/tlpkg/bin/deref-symlinks b/Master/tlpkg/bin/deref-symlinks
new file mode 100755
index 00000000000..3b1dbd6202f
--- /dev/null
+++ b/Master/tlpkg/bin/deref-symlinks
@@ -0,0 +1,22 @@
+#!/bin/sh
+# $Id$
+# Originally written by Karl Berry. Public domain.
+#
+# Replace symlinks to files with the actual files.
+# Symlinks to anything else are not touched.
+
+if test "x$1" = --save-links; then
+ savelinks=true
+else
+ savelinks=false
+fi
+
+for f in "$@"; do
+ test -h "$f" || continue # skip non-symlinks
+ test -f "$f" || continue # skip links to anything but regular files
+
+ cp --dereference "$f" "$f".file # expand link
+ mv "$f" "$f".link # move link out of the way
+ mv -v "$f".file "$f" # replace with regular file
+ $savelinks || rm "$f".link # remove link unless keeping
+done