expanding ../.. sigils in a shell script?
I am writing a Bourne shell script which takes a directory name as an argument. It would be good if the pathname is absolute, and I handle the obvious ~, ~/subdir, ., ./subdir, .., & ../subdir possibilities fine.
However, legitimate relative directory names such as ../.., ../../subdir, ../../../subdir are especially thorny. Is there some obvious way of converting these to absolute pathnames available without me having to manually step through the pathname right-to-left substituting as I go along?
Any insight would be appreciated. Thanks.
|