Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Perl's "do" operator with a variety of absolute paths under Cygwin #7411

Closed
p5pRT opened this issue Jul 7, 2004 · 6 comments
Closed

Perl's "do" operator with a variety of absolute paths under Cygwin #7411

p5pRT opened this issue Jul 7, 2004 · 6 comments

Comments

@p5pRT
Copy link

p5pRT commented Jul 7, 2004

Migrated from rt.perl.org#30633 (status was 'resolved')

Searchable as RT30633$

@p5pRT
Copy link
Author

p5pRT commented Jul 7, 2004

From rbn@vitesse.com

Hello there,

(This question was also posted to cygwin@​cygwin.com).

I've discovered the following oddity with Cygwin Perl v. 5.8.2's "do" operator​:
The following two forms of "do" do work​:
  do "c​:\\foo.pl";
  do "/cygdrive/c/foo.pl";

The following doesn't​:
  do "c​:/foo.pl";

The funny thing is that almost any other Perl function/operator works with
the latter form. The following, for instance, does NOT die (given that
c​:\foo.pl exists, of course)​:
  die 'c​:/foo.pl does not exist' if not -f 'c​:/foo.pl';

Also, other Cygwin programs handle the form well. For instance
  eval `cat u​:/foo.pl`;
also works fine.

What is the problem with the "do" operator?

/René Bøje Nielsen

P.S. I just downloaded and compiled v.5.8.4 under Cygwin, and found it
to have the same strange behavior.

@p5pRT
Copy link
Author

p5pRT commented Nov 2, 2004

From @smpeters

[rbn@​vitesse.com - Wed Jul 07 15​:22​:29 2004]​:

Hello there,

(This question was also posted to cygwin@​cygwin.com).

I've discovered the following oddity with Cygwin Perl v. 5.8.2's "do"
operator​:
The following two forms of "do" do work​:
do "c​:\\foo.pl";
do "/cygdrive/c/foo.pl";

The following doesn't​:
do "c​:/foo.pl";

The funny thing is that almost any other Perl function/operator works
with
the latter form. The following, for instance, does NOT die (given that
c​:\foo.pl exists, of course)​:
die 'c​:/foo.pl does not exist' if not -f 'c​:/foo.pl';

Also, other Cygwin programs handle the form well. For instance
eval `cat u​:/foo.pl`;
also works fine.

What is the problem with the "do" operator?

This problem still exists as of Perl 5.8.5. For example...

Steve Peters@​WindowsPC /tmp/foo
$ perl -e'do "/tmp/foo/foo.pl" or die $!'
Hello
Steve Peters@​WindowsPC /tmp/foo
$ perl -e'do "/cygdrive/c/cygwin/tmp/foo/foo.pl" or die $!'
Hello
Steve Peters@​WindowsPC /tmp/foo
$ perl -e'do "c​:\\cygwin\\tmp\\foo\\foo.pl" or die $!'
Hello
Steve Peters@​WindowsPC /tmp/foo
$ perl -e'do "c​:/cygwin/tmp/foo/foo.pl" or die $!'
No such file or directory at -e line 1.

Steve Peters@​WindowsPC /tmp/foo
$ cat c​:/cygwin/tmp/foo/foo.pl
print "Hello"

Oddly enough, Win32 works just fine in this case​:

C​:\Documents and Settings\Steve Peters>perl -e"do
\"c​:/cygwin/tmp/foo/foo.pl\""
Hello

@p5pRT
Copy link
Author

p5pRT commented Nov 2, 2004

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Nov 3, 2004

From @ysth

On Tue, Nov 02, 2004 at 05​:43​:57AM -0000, Steve Peters via RT wrote​:

I've discovered the following oddity with Cygwin Perl v. 5.8.2's "do"
operator​:
The following two forms of "do" do work​:
do "c​:\\foo.pl";
do "/cygdrive/c/foo.pl";

The following doesn't​:
do "c​:/foo.pl";

This problem still exists as of Perl 5.8.5. For example...

Steve Peters@​WindowsPC /tmp/foo
$ perl -e'do "/tmp/foo/foo.pl" or die $!'
Hello
Steve Peters@​WindowsPC /tmp/foo
$ perl -e'do "/cygdrive/c/cygwin/tmp/foo/foo.pl" or die $!'
Hello
Steve Peters@​WindowsPC /tmp/foo
$ perl -e'do "c​:\\cygwin\\tmp\\foo\\foo.pl" or die $!'
Hello
Steve Peters@​WindowsPC /tmp/foo
$ perl -e'do "c​:/cygwin/tmp/foo/foo.pl" or die $!'
No such file or directory at -e line 1.

Steve Peters@​WindowsPC /tmp/foo
$ cat c​:/cygwin/tmp/foo/foo.pl
print "Hello"

Oddly enough, Win32 works just fine in this case​:

C​:\Documents and Settings\Steve Peters>perl -e"do
\"c​:/cygwin/tmp/foo/foo.pl\""
Hello

Inline Patch
--- util.h.orig	2003-04-16 14:25:37.000000000 -0700
+++ util.h	2004-11-02 16:15:35.288769600 -0800
@@ -16,7 +16,7 @@
 		 && (isALNUM((f)[1]) || strchr("$-_]>",(f)[1])))))
 
 #else		/* !VMS */
-#  ifdef WIN32
+#  if defined(WIN32) || defined(__CYGWIN__)
 #    define PERL_FILE_IS_ABSOLUTE(f) \
 	(*(f) == '/' || *(f) == '\\'		/* UNC/rooted path */	\
 	 || ((f)[0] && (f)[1] == ':'))		/* drive name */
 
End of Patch.

This affects only do and require and some odd code in gv.c that
suppresses a warning in some cases.

@p5pRT
Copy link
Author

p5pRT commented Nov 3, 2004

From @rgs

Yitzchak Scott-Thoennes wrote​:

--- util.h.orig 2003-04-16 14​:25​:37.000000000 -0700
+++ util.h 2004-11-02 16​:15​:35.288769600 -0800
@​@​ -16,7 +16,7 @​@​
&& (isALNUM((f)[1]) || strchr("$-_]>",(f)[1])))))

#else /* !VMS */
-# ifdef WIN32
+# if defined(WIN32) || defined(__CYGWIN__)
# define PERL_FILE_IS_ABSOLUTE(f) \

Looks sensible. Thanks, applied to blead as change 23468.

@p5pRT
Copy link
Author

p5pRT commented Nov 3, 2004

@rgs - Status changed from 'open' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant