[go: nahoru, domu]

blob: 850bbae70faeb7cf7a4da343d92d4efc06ac5191 [file] [log] [blame]
Takuto Ikuta3dab32e02023-01-12 18:52:001#!/usr/bin/env python3
Avi Drissman73a09d12022-09-08 20:33:382# Copyright 2019 The Chromium Authors
Ben Pastene0d77b1882020-06-10 23:31:043# 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())