in reply to Getting the shell's version of working directory, without PWD's help

bash's pushd (and to list, dirs command) seems to track as a LIFO, the specified path to perceived pwd - i.e., the path actually used via series of cds (the only information that can solve this problem of state*). Cwd::Ext appears to do something similar. Unfortunately, there are no useful modules for you to leverage this behavior of pushd via bash. Maybe a useful module to create would be Bash::Pushd::Pwd or something like that.

* See Hysteresis, Path dependence

Replies are listed 'Best First'.
Re^2: Getting the absolute path of a script, without PWD
by perlancar (Hermit) on Jul 16, 2021 at 00:15 UTC
    Cwd::Ext's abs_path_nd uses Cwd's cwd so it still resolves symlinks for retrieving "the current directory" part.