#!/usr/bin/env python3 from sys import argv from os import readlink from os import path def resolve(inpath: str) -> list[str]: output = [] inpath = path.abspath(inpath) dir=path.dirname(inpath) while path.islink(inpath): output.append(inpath) inpath=readlink(inpath) if not path.isabs(inpath): inpath=path.join(dir, inpath) dir=path.dirname(inpath) return output if __name__ == "__main__": for i in argv[1:]: paths=resolve(i) for path in paths: print(path)