| #!/bin/sh |
| # Copyright (c) 2013 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 |
| # option. Note that this implementation of -f implies -m, but that shouldn't |
| # matter as readlink isn't used to find missing directories, only canonicize |
| # paths. |
| |
| |
| if [ "$1" = "-f" ]; then |
| if [ "$2" = "--" ]; then |
| shift |
| fi |
| if [ $# -ne 2 ]; then |
| echo "Usage: readlink -f [--] <path>" >&2 |
| exit 1 |
| fi |
| exec python -c 'import os,sys;print os.path.realpath(sys.argv[1])' "$2" |
| else |
| if [ -x /bin/readlink ]; then |
| exec /bin/readlink "$@" |
| else |
| exec /usr/bin/readlink "$@" |
| fi |
| fi |