in reply to Re: Getting the absolute path of a script, without PWD
in thread Getting the shell's version of working directory, without PWD's help

One reason is for logging path and the symlinked version is more meaningful and/or hides unwanted detail. For example I have a device /media/USER/1234-5678 mounted but I also keep /media/USER/MORE-MEANINGFUL-NAME symlinked to it and want to log the filenames inside the symlinked version. Okay not a great example as I should've just relabeled the removable volume in the first place, but that's the only example I can think of right now. There are other cases I've encountered previously.
  • Comment on Re^2: Getting the absolute path of a script, without PWD

Replies are listed 'Best First'.
Re^3: Getting the absolute path of a script, without PWD
by hippo (Bishop) on Jul 15, 2021 at 12:28 UTC

    Sure - there may be some cases where you might want the symlink name rather than the target. But that's not what you've asked. Your question says "... without PWD". Why impose this arbitrary restriction? If you want what $PWD gives, why not just use it?


    🦛

      Yes, that's just a curiosity. I'm using PWD right now.
Re^3: Getting the absolute path of a script, without PWD
by Tux (Canon) on Jul 15, 2021 at 14:48 UTC

    Find the symlinks and build a reverse hash lookup-table.


    Enjoy, Have FUN! H.Merijn
      This will result in a permutation of possible paths. How would you know which path is the correct one?