blob: 3285ff1d93032775443cb9e2077c5af7eeff1a79 [file] [log] [blame]
Ben Pastene0d77b1882020-06-10 23:31:041#!/usr/bin/env python
2# Copyright (c) 2019 The Chromium Authors. All rights reserved.
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5"""Prints the target paths of the given symlinks.
6
7Prints out each target in the order that the links were passed in.
8"""
9
10import os
11import sys
12
13
14def main():
15 for link_name in sys.argv[1:]:
16 if not os.path.islink(link_name):
17 sys.stderr.write("%s is not a link" % link_name)
18 return 1
19 target = os.readlink(link_name)
20 if not os.path.isabs(target):
21 target = os.path.join(os.path.dirname(link_name), target)
22 print(os.path.realpath(target))
23 return 0
24
25
26if __name__ == '__main__':
27 sys.exit(main())