On Mon, Dec 1, 2008 at 2:04 AM, Paul D. Smith <[EMAIL PROTECTED]> wrote: > > Follow-up Comment #2, bug #24949 (project coreutils): > > The problem is that without -P I can't invoke pwd from things like Perl > portably. If I use "my $pwd = `pwd`;" and it runs a shell and uses the shell > builtin version of pwd, then I get the wrong thing (I explicitly want the > "real" path; what POSIX defines "pwd -P" to return). > > But on the other hand, if I use "my $pwd = `pwd -P`;", which is what a > correct POSIX-conforming script would do, and it runs coreutils pwd instead of > a shell builtin, I get a syntax error.
If you can rely enough on the platform being POSIX-conforming for -P to work, then why not just use Perl's POSIX module? It seems to me that that would be more portable still. ~$ cat pwd.pl #! /usr/bin/perl use POSIX qw(getcwd); print "1: " . POSIX::getcwd() . "\n"; my $pwd = `pwd`; chop($pwd); print "2: " . $pwd . "\n"; my $pwd = `pwd -P 2>/dev/null || pwd`; chop($pwd); print "3: " . $pwd . "\n"; ~$ perl pwd.pl 1: /home/james 2: /home/james 3: /home/james James. _______________________________________________ Bug-coreutils mailing list Bug-coreutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-coreutils