blob: 156aa0478689d1fa87543726de5c1082c1f62e9f [file] [log] [blame] [edit]
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright 2018 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""An alternate implementation of readlink that supports the non-standard -f.
Note that this implementation of -f implies -m, but that shouldn't matter as
readlink isn't used to find missing directories, only canonicalize paths.
"""
from __future__ import print_function
import os
import sys
import libdot
def get_parser():
"""Get a command line parser."""
parser = libdot.ArgumentParser(description=__doc__)
parser.add_argument('-f', '--canonicalize', action='store_true',
help='Canonicalize the paths.')
parser.add_argument('paths', nargs='+',
help='Paths to process.')
return parser
def main(argv):
"""The main func!"""
parser = get_parser()
opts = parser.parse_args(argv)
for path in opts.paths:
print(os.path.realpath(path))
if __name__ == '__main__':
sys.exit(main(sys.argv[1:]))