Skip to content

Commit 0b05dec

Browse files
committed
Use readlink to canonicalize path to script
readlink without `-f` will return the relative value of the symlink and realpath will fail for values such as `../scm/repo/script.sh` when this is in `~/bin` and the script is called via the path. readlink will properly canonicalize the path when `-f` is specified, therefore just use it if available. readlink on MacOS does not support it.
1 parent 5f65dfd commit 0b05dec

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

copyright-year-updater.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#====================================================================
33
# copyright-year-updater.sh
44
#
5-
# Copyright 2015-2017 Fwolf <fwolf.aide+bin.public@gmail.com>
5+
# Copyright 2015-2017, 2020 Fwolf <fwolf.aide+bin.public@gmail.com>
66
# All rights reserved.
77
#
88
# Distributed under the MIT License.
@@ -17,8 +17,7 @@ VERSION=0.2.4
1717

1818
self="$0"
1919
if [ -L "$self" ]; then
20-
self=$(readlink "$self")
21-
self=$(realpath "$self")
20+
self=$(readlink -f "$self" || realpath "$(readlink "$self")")
2221
fi
2322
P2R=${self%/*}/
2423

0 commit comments

Comments
 (0)