Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

comment on

( [id://3333] : superdoc . print w/replies, xml ) Need Help??
This seems to be a portability issue.

cwd()."\n" eq `pwd -L`

  • holds for termux, win10
  • fails for my (old) ubuntu in a VM

I'd say file a bugreport against Cwd and in the meantime resort to `pwd` or `pwd -L` on systems where it fails.

update

after further investigation, it seems that `pwd` inside Perl doesn't default like pwd in bash ... which is unexpected

lanx@ubuntu14-large:/tmp/sym$ perl -MCwd -E'say `pwd` ' /tmp/dir lanx@ubuntu14-large:/tmp/sym$ pwd /tmp/sym lanx@ubuntu14-large:/tmp/sym$ perl -MCwd -E'say `pwd -L` ' /tmp/sym lanx@ubuntu14-large:/tmp/sym$

so strictly speaking, this is not a bug in Cwd, since cwd() returns the same like `pwd` (which does not always -L )

The question is why is bash's pwd defaulting differently inside Perl?

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


In reply to Re^4: Getting the absolute path of a script, without PWD (bug?)(update) by LanX
in thread Getting the shell's version of working directory, without PWD's help by perlancar

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.