From 7971cb0aa3e517a53f0ce6d3ee9bc3179041ccb8 Mon Sep 17 00:00:00 2001 From: John Klug Date: Wed, 25 May 2022 17:12:18 -0500 Subject: mLinux 6 --- scripts/lnr | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 scripts/lnr (limited to 'scripts/lnr') diff --git a/scripts/lnr b/scripts/lnr new file mode 100755 index 0000000..9dacebe --- /dev/null +++ b/scripts/lnr @@ -0,0 +1,21 @@ +#! /usr/bin/env python + +# Create a *relative* symlink, just like ln --relative does but without needing +# coreutils 8.16. + +import sys, os + +if len(sys.argv) != 3: + print "$ lnr TARGET LINK_NAME" + sys.exit(1) + +target = sys.argv[1] +linkname = sys.argv[2] + +if os.path.isabs(target): + if not os.path.isabs(linkname): + linkname = os.path.abspath(linkname) + start = os.path.dirname(linkname) + target = os.path.relpath(target, start) + +os.symlink(target, linkname) -- cgit v1.2.3