Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^3: Getting the absolute path of a script, without PWD (update)

by LanX (Sage)
on Jul 15, 2021 at 13:06 UTC ( #11135029=note: print w/replies, xml ) Need Help??


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

You've replied to my update without reading it.

getcwd and cwd are different and it's clearly documented

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

  • Comment on Re^3: Getting the absolute path of a script, without PWD (update)

Replies are listed 'Best First'.
Re^4: Getting the absolute path of a script, without PWD (update)
by perlancar (Hermit) on Jul 15, 2021 at 23:45 UTC
    I've tested both cwd() and getcwd() before, and looked at the source. They both resolve symlinks. And the pwd and PWD variable from bash are not the same.

    UPDATE:Okay, so when we type pwd in bash by default we get the shell builtin, not the external Unix utility (/bin/pwd on my system). And the shell's pwd defaults to -L (logical) and we get the bash PWD. The external Unix utility defaults to -P (physical) which resolves symlinks. And if we run /bin/pwd -L, it still retrieves from PWD environment variable. Confirming my original question, we do need PWD and there's no way in Perl we can get the same version without PWD.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11135029]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (2)
As of 2021-09-26 14:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?