1
0
forked from brl/citadel
citadel/scripts/lnr
brl 098b8f982b Squashed 'poky/' content from commit 4469acdf1d
git-subtree-dir: poky
git-subtree-split: 4469acdf1d0338220f3fe2ecb5e079eea6fda375
2017-12-04 16:35:29 -05:00

22 lines
473 B
Python
Executable File

#! /usr/bin/env python3
# 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)