From 2665af78b6ba1bf51d7bee3c2c01bbc6213e3ab1 Mon Sep 17 00:00:00 2001 From: Ain <41307858+nero@users.noreply.github.com> Date: Tue, 20 Mar 2018 18:03:13 +0000 Subject: [PATCH] Fix relative . or .. symlinks --- realpath.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/realpath.sh b/realpath.sh index d114d30..c356e23 100755 --- a/realpath.sh +++ b/realpath.sh @@ -27,13 +27,12 @@ while [ -n "$left" ]; do case "$seg" in .) - # /foo/a -> . will become /foo - result="${result%/*}" + # Just ignore this segment continue ;; ..) - # /foo/bar/a -> .. will become /foo - result="${result%/*/*}" + # Eat a segment off result + result="${result%/*}" continue ;; esac