Is it possible to convert in a shell script a user input path (absolute or relative) to the absolute path but without losing the symlinks inside, e.g. /a/b/c is the current user dir and c is a symlink to /a/b/s:
input . => result /a/b/c
input ./d => result /a/b/c/d
input ../c => result /a/b/c
input /a/b/c => result /a/b/c
(readlink converts it to /a/b/s, but I need /a/b/c)
..
is contradictory: iff
is a symlink to/elsewhere
, forf/../stuff
, do you want/a/b/stuff
(eliminating..
without looking up symlinks, but you end up with a path that doesn't lead to the same file) or/elsewhere/stuff
(which is correct but doesn't go through a symlink) or/a/b/f/../stuff
(which is correct but retains..
)? The considerations in http://unix.stackexchange.com/questions/9123/is-there-a-one-liner-that-allows-me-to-create-a-directory-and-move-into-it-at-th/9124#9124 may be of interest. – Gilles 'SO- stop being evil' Mar 05 '15 at 22:54