File: readlink-fn.py

package info (click to toggle)
upx-ucl 4.2.4-1.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 16,168 kB
  • sloc: ansic: 99,906; cpp: 60,585; asm: 32,273; python: 1,573; makefile: 1,353; sh: 1,143
file content (15 lines) | stat: -rwxr-xr-x 440 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#! /usr/bin/env python3
## vim:set ts=4 sw=4 et: -*- coding: utf-8 -*-

# simulate "readlink -fn FILE" for systems that lack it (e.g. macOS-11)
# - result may differ from actual readlink(1) for edge cases
# - works with Python2 and Python3
#
# Copyright (C) Markus Franz Xaver Johannes Oberhumer

import os, sys
if len(sys.argv) != 2:
    sys.exit(1)
real_path = os.path.realpath(sys.argv[1])
sys.stdout.write(real_path)
sys.stdout.flush()