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

The blank in option "-x directory" should be deleted from perlrun.pod #8988

Closed
p5pRT opened this issue Aug 3, 2007 · 29 comments
Closed

The blank in option "-x directory" should be deleted from perlrun.pod #8988

p5pRT opened this issue Aug 3, 2007 · 29 comments

Comments

@p5pRT
Copy link

p5pRT commented Aug 3, 2007

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

Searchable as RT44387$

@p5pRT
Copy link
Author

p5pRT commented Aug 3, 2007

From yuzg@cn.fujitsu.com

Hello Mr. Larry Wall,

  I find a bug in perlrun.pod(stable release perl-5.8.8 and Development
Release perl-5.9.3)​:
  The blank in option "-x directory" should be deleted.

  Use option '-x' can tell Perl that the program is embedded in a larger
chunk of unrelated ASCII text, If a directory name is specified, Perl will
switch to that directory before running the program.
  The relative description in perlrun.pod is wrong, the method to specify
the directory is '-xdirectory' rather than '-x directory'.

  This problem can reproduce by the following code​:
---------------------------------mytest.pl-------------------------------------
Before the #! line
#!/usr/bin/perl
mkdir "./mydir";
__END__
After the __END__ line


The method to confirm this bug is as follows​:


  1) use '-x directory'​:
  [root@​localhost ~]# mkdir -p mydir
  [root@​localhost ~]# perl -x mydir mytest.pl
  No Perl script found in input
  [root@​localhost ~]# ls mydir/
  [root@​localhost ~]#

  2) use '-xdirectory'​:
  [root@​localhost ~]# mkdir -p mydir
  [root@​localhost ~]# perl -xmydir mytest.pl
  [root@​localhost ~]# ls mydir/
  mydir2


  I have made two patchs for perlrun.pod in stable release perl-5.8.8 and
Development Release perl-5.9.3.
  Could you confirm and apply them in the next release?

  Thanks a lot.

Regards
Yu Zhiguo


Fixing this description error in perlrun.pod​:

  1) The patch for stable release perl-5.8.8


Inline Patch
--- perl-5.8.8/pod/perlrun.pod.orig     2007-08-04 00:53:28.000000000 +0800
+++ perl-5.8.8/pod/perlrun.pod  2007-08-04 00:54:40.000000000 +0800
@@ -949,7 +949,7 @@
 =item B<-x>
 X<-x>

-=item B<-x> I<directory>
+=item B<-x>I<directory>

 tells Perl that the program is embedded in a larger chunk of unrelated
 ASCII text, such as in a mail message.  Leading garbage will be
-------------------------------------------------------------------------------

    2) The patch for Development Release perl-5.9.3
-------------------------------------------------------------------------------
--- perl-5.9.3/pod/perlrun.pod.orig     2007-08-04 00:28:20.000000000 +0800
+++ perl-5.9.3/pod/perlrun.pod  2007-08-04 00:35:20.000000000 +0800
@@ -972,7 +972,7 @@
 =item B<-x>
 X<-x>

-=item B<-x> I<directory>
+=item B<-x>I<directory>

 tells Perl that the program is embedded in a larger chunk of unrelated
 ASCII text, such as in a mail message.  Leading garbage will be
-------------------------------------------------------------------------------

@p5pRT
Copy link
Author

p5pRT commented Aug 3, 2007

From yuzg@cn.fujitsu.com

perlrun.pod.5.8.8.patch
--- perl-5.8.8/pod/perlrun.pod.orig	2007-08-04 00:53:28.000000000 +0800
+++ perl-5.8.8/pod/perlrun.pod	2007-08-04 00:54:40.000000000 +0800
@@ -949,7 +949,7 @@
 =item B<-x>
 X<-x>
 
-=item B<-x> I<directory>
+=item B<-x>I<directory>
 
 tells Perl that the program is embedded in a larger chunk of unrelated
 ASCII text, such as in a mail message.  Leading garbage will be

@p5pRT
Copy link
Author

p5pRT commented Aug 3, 2007

From yuzg@cn.fujitsu.com

perlrun.pod.5.9.3.patch
--- perl-5.9.3/pod/perlrun.pod.orig	2007-08-04 00:28:20.000000000 +0800
+++ perl-5.9.3/pod/perlrun.pod	2007-08-04 00:35:20.000000000 +0800
@@ -972,7 +972,7 @@
 =item B<-x>
 X<-x>
 
-=item B<-x> I<directory>
+=item B<-x>I<directory>
 
 tells Perl that the program is embedded in a larger chunk of unrelated
 ASCII text, such as in a mail message.  Leading garbage will be

@p5pRT
Copy link
Author

p5pRT commented Aug 4, 2007

From steven@accognoscere.org

Confirmed (as of #31680).

Albeit nicely spotted, it is recommended practice to create diffs
against latest bleadperl (see "perlhack" for appropriate hints). Once
applied to bleadperl, the changes will be backported to maint (assuming
they're applicable).

I'm of the opinion that removing the separating space between "-x
directory" would cause some confusion, because it'd result in
"-xdirectory" if the formatting tags were omitted (as in ``raw" output,
for example). How should one differentiate the parameter and the
argument by purely looking at the POD (given that raw output was
created) and not consulting the output of `perl -h` ?

Perhaps it'd be more sensible to wrap "-xdirectory" in something like
"-x<directory>" ?

@p5pRT
Copy link
Author

p5pRT commented Aug 4, 2007

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

@p5pRT
Copy link
Author

p5pRT commented Aug 4, 2007

From guest@guest.guest.xxxxxxxx

Hello,

Thanks for your reply.
I think there will be no confusion, and we don't need to use the
wrapping format like "-x<directory>".

I agree after consulting the output of "perl --help", users can get
the clear usage of "-x", because the output is "-x[directory]".

But I think we should not use wrapping format in perlrun.pod, because​:


1) using commands "man perlrun.man"(*.man comes from *.pod)
and "perldoc perlrun.pod", the output is about "-x" is​:
  -x -------> specify can be used singly
  -xdirectory -------> the is a underline on word "directory"

2) in the description of "-x" is contains​:
  "If a directory name is specified, Perl will switch to that
directory before running the program."
So, the user will know the "directory" is optional.

3) the output format
  -x
  -xdirectory -------> the is a underline on word "directory"

is the same with option "-d"​:
  -d
  -dt -------> word "t" is boldface,
  and there has description "If t is specified, ..."


So, I think there will be no confusion, and we don't need to use the
wrapping format like "-x<directory>".

If use wrapping format,


I think we'd better use "-x[directory]" rather than "-x<directory>",
and we must delete the singly "-x"​:

  -x[directory] -------> the is a underline on word "directory"

because it is compatible with option "-0[octal/hexadecimal]"

  -0[octal/hexadecimal] -> the is a underline on octal/hexadecimal


In conclusion, I think we'd better use the format​:
  -x
  -xdirectory -------> the is a underline on word "directory"
Do you agree with me?

Thanks.

@p5pRT
Copy link
Author

p5pRT commented Aug 6, 2007

From @davidnicol

Perhaps it'd be more sensible to wrap "-xdirectory" in something like
"-x<directory>" ?

Or fix the argument parsing so that perl matches the current documentation?

--
Prioritize based on common sense?
Is that some kind of joke?

@p5pRT
Copy link
Author

p5pRT commented Aug 6, 2007

From jns@gellyfish.com

On Mon, 2007-08-06 at 13​:09 -0500, David Nicol wrote​:

Perhaps it'd be more sensible to wrap "-xdirectory" in something like
"-x<directory>" ?

Or fix the argument parsing so that perl matches the current documentation?

It would seem that most of the options allow having either space or no
space so I'd concur with this.

/J\
--
This signature kills fascists

@p5pRT
Copy link
Author

p5pRT commented Aug 6, 2007

From @jdhedden

The attached patch allows both '-xdirectory' and '-x directory' to
work as expected.

@p5pRT
Copy link
Author

p5pRT commented Aug 6, 2007

From @jdhedden

minus_x.patch
--- perl-current/perl.c
+++ perl-current/perl.c
@@ -1997,8 +1997,12 @@
 	case 'x':
 	    PL_doextract = TRUE;
 	    s++;
-	    if (*s)
+	    if (*s) {
 		cddir = s;
+	    } else if ((s = argv[1]) && (*s != '-')) {
+		argc--,argv++;
+		chdir = s;
+	    }
 	    break;
 	case 0:
 	    break;

@p5pRT
Copy link
Author

p5pRT commented Aug 8, 2007

From @ysth

On Wed, August 8, 2007 11​:47 am, Abhijit Menon-Sen wrote​:

At 2007-08-06 14​:47​:57 -0400, jdhedden@​cpan.org wrote​:

The attached patch allows both '-xdirectory' and '-x directory' to
work as expected.

Actually, it would cause a compile error because the variable is named
"cddir", not "chdir".

This seems a dangerous change; how do you indicate that you don't want -x to
swallow the next parameter?

$ cat foo
initial junk
#!perl -l
print "\@​ARGV​: @​ARGV"

$ perl -x foo bar
@​ARGV​: bar

$ perl5.9.5 -x foo bar
Can't open perl script "bar"​: No such file or directory

This seems to trip up the switch tests, too.

@p5pRT
Copy link
Author

p5pRT commented Aug 8, 2007

From ams@toroid.org

At 2007-08-06 14​:47​:57 -0400, jdhedden@​cpan.org wrote​:

The attached patch allows both '-xdirectory' and '-x directory' to
work as expected.

Actually, it would cause a compile error because the variable is named
"cddir", not "chdir".

-- ams

Change 31690 by ams@​penne on 2007/08/08 18​:45​:34

  Make '-xx' and '-x x' work the same way (see #44387).

Affected files ...

... //depot/perl/perl.c#817 edit

Differences ...

==== //depot/perl/perl.c#817 (text) ====

@​@​ -1997,8 +1997,13 @​@​
  case 'x'​:
  PL_doextract = TRUE;
  s++;
- if (*s)
+ if (*s) {
+ cddir = s;
+ }
+ else if ((s=argv[1]) && *s != '-') {
+ argc--,argv++;
  cddir = s;
+ }
  break;
  case 0​:
  break;

@p5pRT
Copy link
Author

p5pRT commented Aug 8, 2007

From @jdhedden

The attached patch allows both '-xdirectory' and '-x directory' to
work as expected.

This seems a dangerous change; how do you indicate that you don't want -x to
swallow the next parameter?

$ cat foo
initial junk
#!perl -l
print "\@​ARGV​: @​ARGV"

$ perl -x foo bar
@​ARGV​: bar

$ perl5.9.5 -x foo bar
Can't open perl script "bar"​: No such file or directory

This seems to trip up the switch tests, too.

Just noticed this myself. I'm working on a follow-on patch complete with tests.

@p5pRT
Copy link
Author

p5pRT commented Aug 8, 2007

From @jdhedden

how do you indicate that you don't want -x to
swallow the next parameter?

(Sorry, forgot to answer your question.)

The patch I'm planning tests that the next arg is a directory.
If so, it uses it.

--- perl-current/perl.c
+++ perl-current/perl.c
@​@​ -2000,9 +2000,14 @​@​
  if (*s) {
  cddir = s;
  }
+ /* If following arg is a dir, then use it */
  else if ((s=argv[1]) && *s != '-') {
- argc--,argv++;
- cddir = s;
+ DIR *dir;
+ if ((dir = PerlDir_open(s))) {
+ PerlDir_close(dir);
+ argc--,argv++;
+ cddir = s;
+ }
  }
  break;
  case 0​:

Is this okay?

@p5pRT
Copy link
Author

p5pRT commented Aug 8, 2007

From @ysth

On Wed, August 8, 2007 1​:28 pm, Jerry D. Hedden wrote​:

how do you indicate that you don't want -x to swallow the next
parameter?

The patch I'm planning tests that the next arg is a directory.
If so, it uses it.

+ DIR *dir;
+ if ((dir = PerlDir_open(s))) {
+ PerlDir_close(dir);
+ argc--,argv++;
+ cddir = s;
+ }

Is this okay?

Not sure. To chdir, you only need execute access, not read access (which the
open will test for).

@p5pRT
Copy link
Author

p5pRT commented Aug 8, 2007

From @jdhedden

The patch I'm planning tests that the next arg is a
directory. If so, it uses it.

+ DIR *dir;
+ if ((dir = PerlDir_open(s))) {
+ PerlDir_close(dir);
+ argc--,argv++;
+ cddir = s;
+ }

Is this okay?

Not sure. To chdir, you only need execute access, not
read access (which the open will test for).

Argh. Would someone please help me with what the equivalent
of "(-d dir)" would be to use in perl.c?

@p5pRT
Copy link
Author

p5pRT commented Aug 8, 2007

From @jdhedden

My previous patch (which became change 31690) broke '-x'.

Attached patch fixes this, and adds tests for '-x', '-x dir' and '-xdir'.

(I actually compiled and tested it this time.)

@p5pRT
Copy link
Author

p5pRT commented Aug 8, 2007

From @jdhedden

switch_x.patch
diff -urN perl-current/MANIFEST perl-current/MANIFEST
--- perl-current/MANIFEST
+++ perl-current/MANIFEST
@@ -3876,6 +3876,7 @@
 t/run/switchPx.t		Test the -Px combination
 t/run/switcht.t			Test the -t switch
 t/run/switchx.aux		Data for switchx.t
+t/run/switchx.aux2		Data for switchx.t
 t/run/switchx.t			Test the -x switch
 t/TEST				The regression tester
 t/TestInit.pm			Preamble library for core tests
diff -urN perl-current/perl.c perl-current/perl.c
--- perl-current/perl.c
+++ perl-current/perl.c
@@ -2000,9 +2000,14 @@
 	    if (*s) {
 		cddir = s;
 	    }
+	    /* If following arg is a dir, then use it */
 	    else if ((s=argv[1]) && *s != '-') {
-		argc--,argv++;
-		cddir = s;
+		DIR *dir;
+		if ((dir = PerlDir_open(s))) {
+		    PerlDir_close(dir);
+		    argc--,argv++;
+		    cddir = s;
+		}
 	    }
 	    break;
 	case 0:
diff -urN perl-current/t/run/switchx.aux perl-current/t/run/switchx.aux
--- perl-current/t/run/switchx.aux
+++ perl-current/t/run/switchx.aux
@@ -17,5 +17,13 @@
 
 #!/some/path/that/leads/to/perl -l
 
-print "1..1";
-print "ok 1";
+print "1..6";
+if (-f 'run/switchx.aux') {
+    print "ok 1";
+}
+print "ok 2";
+
+__END__
+
+# This is ignored
+print "not ok 2";
diff -urN perl-current/t/run/switchx.aux2 perl-current/t/run/switchx.aux2
--- perl-current/t/run/switchx.aux2
+++ perl-current/t/run/switchx.aux2
@@ -0,0 +1,32 @@
+From: foo@bar.xx
+Date: Jan 1, 2037 12:34 PM
+Subject: Ignore mail header
+To: perl@perl.xx
+
+#perl
+Not perl
+
+#!
+Still not perl
+
+#!/something/else
+Still not perl
+
+#!/usr/bin/bash
+# Ingore shell commands
+if [[ -z $FOO ]]; then echo 'not ok 1'; fi
+
+#!/some/path/that/leads/to/perl -l
+
+# These perl command get executed
+my $test = $ARGV[0];
+if (-f 'switchx.t') {
+    print("ok $test");
+}
+$test++;
+print "ok $test";
+
+__END__
+
+# This is ignored
+print "not ok $test";
diff -urN perl-current/t/run/switchx.t perl-current/t/run/switchx.t
--- perl-current/t/run/switchx.t
+++ perl-current/t/run/switchx.t
@@ -8,4 +8,18 @@
 require './test.pl';
 use File::Spec::Functions;
 
-print runperl( switches => ['-x'], progfile => catfile(curdir(), 'run', 'switchx.aux') );
+# Test '-x'
+print runperl( switches => ['-x'],
+               progfile => catfile(curdir(), 'run', 'switchx.aux') );
+
+# Test '-x dir'
+print runperl( switches => ['-x', catfile(curdir(), 'run')],
+               progfile => catfile(curdir(), 'run', 'switchx.aux2'),
+               args     => [ 3 ] );
+
+# Test '-xdir'
+print runperl( switches => ['-x' . catfile(curdir(), 'run')],
+               progfile => catfile(curdir(), 'run', 'switchx.aux2'),
+               args     => [ 5 ] );
+
+# EOF

@p5pRT
Copy link
Author

p5pRT commented Aug 8, 2007

From @davidnicol

Inline Patch
--- CURRENT/pod/perlrun.pod     2007-01-24 05:24:57.000000000 -0600
+++ CURRENT_modified/pod/perlrun.pod    2007-08-08 18:04:54.000000000 -0500
@@ -981,7 +981,7 @@
 =item B<-x>
 X<-x>

-=item B<-x> I<directory>
+=item B<-x>I<directory>

 tells Perl that the program is embedded in a larger chunk of unrelated
 ASCII text, such as in a mail message.  Leading garbage will be
@@ -994,6 +994,9 @@
 can process any or all of the trailing garbage via the DATA filehandle
 if desired).

+The directory, if specified, must appear immedately following the B<-x>
+with no intervening whitespace.
+
 =back

 =head1 ENVIRONMENT

@p5pRT
Copy link
Author

p5pRT commented Aug 8, 2007

From @jdhedden

'-x' and '-xdir' work as before. For '-x dir', it checks if the
argument after -x is a directory using PerlLIO_stat(). If it is, it
"eats the argument" and uses it just as in '-xdir'.

The patch includes tests for all this.

@p5pRT
Copy link
Author

p5pRT commented Aug 8, 2007

From @jdhedden

switch_x.patch
diff -urN perl-current/MANIFEST perl-patched/MANIFEST
--- perl-current/MANIFEST	2007-08-08 15:39:37.000000000 -0400
+++ perl-patched/MANIFEST	2007-08-08 15:40:14.000000000 -0400
@@ -3876,6 +3876,7 @@
 t/run/switchPx.t		Test the -Px combination
 t/run/switcht.t			Test the -t switch
 t/run/switchx.aux		Data for switchx.t
+t/run/switchx.aux2		Data for switchx.t
 t/run/switchx.t			Test the -x switch
 t/TEST				The regression tester
 t/TestInit.pm			Preamble library for core tests
diff -urN perl-current/perl.c perl-patched/perl.c
--- perl-current/perl.c	2007-08-08 19:00:39.872250000 -0400
+++ perl-patched/perl.c	2007-08-08 19:13:38.524500000 -0400
@@ -1997,8 +1997,19 @@
 	case 'x':
 	    PL_doextract = TRUE;
 	    s++;
-	    if (*s)
+	    if (*s) {
 		cddir = s;
+	    }
+	    /* If following arg is a dir, then use it */
+	    else if ((s=argv[1]) && *s != '-') {
+		Stat_t tmpstatbuf;
+		if (PerlLIO_stat(s, &tmpstatbuf) >= 0 &&
+		    S_ISDIR(tmpstatbuf.st_mode))
+		{
+		    argc--,argv++;
+		    cddir = s;
+		}
+	    }
 	    break;
 	case 0:
 	    break;
diff -urN perl-current/t/run/switchx.aux perl-patched/t/run/switchx.aux
--- perl-current/t/run/switchx.aux	2007-08-08 15:40:49.000000000 -0400
+++ perl-patched/t/run/switchx.aux	2007-08-08 19:30:37.517750000 -0400
@@ -17,5 +17,13 @@
 
 #!/some/path/that/leads/to/perl -l
 
-print "1..1";
-print "ok 1";
+print "1..6";
+if (-f 'run/switchx.aux') {
+    print "ok 1";
+}
+print "ok 2";
+
+__END__
+
+# This is ignored
+print "not ok 2";
diff -urN perl-current/t/run/switchx.aux2 perl-patched/t/run/switchx.aux2
--- perl-current/t/run/switchx.aux2	1969-12-31 19:00:00.000000000 -0500
+++ perl-patched/t/run/switchx.aux2	2007-08-08 16:07:58.000000000 -0400
@@ -0,0 +1,32 @@
+From: foo@bar.xx
+Date: Jan 1, 2037 12:34 PM
+Subject: Ignore mail header
+To: perl@perl.xx
+
+#perl
+Not perl
+
+#!
+Still not perl
+
+#!/something/else
+Still not perl
+
+#!/usr/bin/bash
+# Ingore shell commands
+if [[ -z $FOO ]]; then echo 'not ok 1'; fi
+
+#!/some/path/that/leads/to/perl -l
+
+# These perl command get executed
+my $test = $ARGV[0];
+if (-f 'switchx.t') {
+    print("ok $test");
+}
+$test++;
+print "ok $test";
+
+__END__
+
+# This is ignored
+print "not ok $test";
diff -urN perl-current/t/run/switchx.t perl-patched/t/run/switchx.t
--- perl-current/t/run/switchx.t	2007-08-08 15:40:49.000000000 -0400
+++ perl-patched/t/run/switchx.t	2007-08-08 19:30:49.408375000 -0400
@@ -8,4 +8,18 @@
 require './test.pl';
 use File::Spec::Functions;
 
-print runperl( switches => ['-x'], progfile => catfile(curdir(), 'run', 'switchx.aux') );
+# Test '-x'
+print runperl( switches => ['-x'],
+               progfile => catfile(curdir(), 'run', 'switchx.aux') );
+
+# Test '-x dir'
+print runperl( switches => ['-x', catfile(curdir(), 'run')],
+               progfile => catfile(curdir(), 'run', 'switchx.aux2'),
+               args     => [ 3 ] );
+
+# Test '-xdir'
+print runperl( switches => ['-x' . catfile(curdir(), 'run')],
+               progfile => catfile(curdir(), 'run', 'switchx.aux2'),
+               args     => [ 5 ] );
+
+# EOF

@p5pRT
Copy link
Author

p5pRT commented Aug 9, 2007

From @jdhedden

On 8/8/07, David Nicol <davidnicol@​gmail.com> wrote​:

--- CURRENT/pod/perlrun.pod 2007-01-24 05​:24​:57.000000000 -0600
+++ CURRENT_modified/pod/perlrun.pod 2007-08-08 18​:04​:54.000000000 -0500
@​@​ -981,7 +981,7 @​@​
=item B<-x>
X<-x>

-=item B<-x> I<directory>
+=item B<-x>I<directory>

tells Perl that the program is embedded in a larger chunk of unrelated
ASCII text, such as in a mail message. Leading garbage will be
@​@​ -994,6 +994,9 @​@​
can process any or all of the trailing garbage via the DATA filehandle
if desired).

+The directory, if specified, must appear immedately following the B<-x>
+with no intervening whitespace.
+
=back

=head1 ENVIRONMENT

Wait a sec. Let's not all give up on this. I am testing a patch
right now that will make it work. There should be no trouble in
'eating' a directory argument after a -x because perl won't execute a
directory. Let me post the patch, you guys review it and then let's
go from there. Thanks.

@p5pRT
Copy link
Author

p5pRT commented Aug 9, 2007

From ams@toroid.org

At 2007-08-08 12​:57​:01 -0700, sthoenna@​efn.org wrote​:

This seems a dangerous change; how do you indicate that you don't want
-x to swallow the next parameter?

Yeah. And it doesn't seem worthwhile to check if the next argument
happens to be a directory name either, because that will either not
matter at all, or break existing scripts (given the old behaviour).
So I reverted #31690. I'll apply that "-x<dir>" patch if someone
wants to submit it.

-- ams

@p5pRT
Copy link
Author

p5pRT commented Aug 9, 2007

From jjuran@gmail.com

On Aug 8, 2007, at 2​:02 PM, Jerry D. Hedden wrote​:

The patch I'm planning tests that the next arg is a
directory. If so, it uses it.

+ DIR *dir;
+ if ((dir = PerlDir_open(s))) {
+ PerlDir_close(dir);
+ argc--,argv++;
+ cddir = s;
+ }

Is this okay?

Not sure. To chdir, you only need execute access, not
read access (which the open will test for).

Argh. Would someone please help me with what the equivalent
of "(-d dir)" would be to use in perl.c?

In straight POSIX/C++ it's

  struct stat stat_buf;
 
  bool is_dir = stat( path, &stat_buf ) == 0 && S_ISDIR
( stat_buf.st_mode );

Josh

@p5pRT
Copy link
Author

p5pRT commented Aug 9, 2007

From @jdhedden

This seems a dangerous change; how do you indicate that
you don't want -x to swallow the next parameter?

Yeah. And it doesn't seem worthwhile to check if the next
argument happens to be a directory name either, because
that will either not matter at all, or break existing
scripts (given the old behaviour). So I reverted #31690.
I'll apply that "-x<dir>" patch if someone wants to submit
it.

I don't see how it would break existing scripts. Can you
come up with an example?

@p5pRT
Copy link
Author

p5pRT commented Aug 9, 2007

From @jandubois

On Wed, 08 Aug 2007, Jerry D. Hedden wrote​:

This seems a dangerous change; how do you indicate that you don't
want -x to swallow the next parameter?
Yeah. And it doesn't seem worthwhile to check if the next
argument happens to be a directory name either, because
that will either not matter at all, or break existing
scripts (given the old behaviour). So I reverted #31690.
I'll apply that "-x<dir>" patch if someone wants to submit
it.

I don't see how it would break existing scripts. Can you
come up with an example?

Sure​:

  perl -S -x foo

This will search the PATH for "foo" (and "foo.bat" and "foo.cmd"
on Windows; "foo.pl" and "foo.com" on VMS; etc).

If you now happen to have a directory called "foo" in the current
directory, then the command above will try to read the script
from STDIN instead of looking for "foo" on the PATH.

Cheers,
-Jan

@p5pRT
Copy link
Author

p5pRT commented Aug 9, 2007

From @jdhedden

On 8/8/07, Jan Dubois <jand@​activestate.com> wrote​:

On Wed, 08 Aug 2007, Jerry D. Hedden wrote​:

This seems a dangerous change; how do you indicate that you don't
want -x to swallow the next parameter?
Yeah. And it doesn't seem worthwhile to check if the next
argument happens to be a directory name either, because
that will either not matter at all, or break existing
scripts (given the old behaviour). So I reverted #31690.
I'll apply that "-x<dir>" patch if someone wants to submit
it.

I don't see how it would break existing scripts. Can you
come up with an example?

Sure​:

perl \-S \-x foo

This will search the PATH for "foo" (and "foo.bat" and "foo.cmd"
on Windows; "foo.pl" and "foo.com" on VMS; etc).

If you now happen to have a directory called "foo" in the current
directory, then the command above will try to read the script
from STDIN instead of looking for "foo" on the PATH.

Okay. Punt.

@p5pRT
Copy link
Author

p5pRT commented Aug 9, 2007

From ams@toroid.org

At 2007-08-08 18​:06​:16 -0500, davidnicol@​gmail.com wrote​:

--- CURRENT/pod/perlrun.pod 2007-01-24 05​:24​:57.000000000 -0600
+++ CURRENT_modified/pod/perlrun.pod 2007-08-08 18​:04​:54.000000000 -0500
@​@​ -981,7 +981,7 @​@​

Thanks, applied. (#31692)

-- ams

@p5pRT
Copy link
Author

p5pRT commented Apr 27, 2008

p5p@spam.wizbit.be - Status changed from 'open' to 'resolved'

@p5pRT p5pRT closed this as completed Apr 27, 2008
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant