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

System command starting with environment variable on HP-UX #1065

Closed
p5pRT opened this issue Jan 21, 2000 · 5 comments
Closed

System command starting with environment variable on HP-UX #1065

p5pRT opened this issue Jan 21, 2000 · 5 comments

Comments

@p5pRT
Copy link
Collaborator

@p5pRT p5pRT commented Jan 21, 2000

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

Searchable as RT2017$

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Jan 21, 2000

From dougw@safeguard.net

This is a bug report for perl from dougw@​safeguard.net,
generated with the help of perlbug 1.26 running under perl 5.00503.


A non zero status is returned from the
system() function when the supplied command
begins with an environment variable setting
where the environment variable contains an
underscore or a digit. such as​:

system('tmp_junk=5 ls') and die "Error​:$!";
or​:
system('tmp_junk1=5 ls') and die "Error​:$!";

Even though such a command will work from the command
line and return a successful status of zero e.g., the
following works on the command line (and outputs
the results from ls)​:

tmp_junk=5 ls
or​:
sh -c "tmp_junk=5 ls"



Site configuration information for perl 5.00503​:

Configured by dougw at Fri Jan 21 08​:43​:13 PST 2000.

Summary of my perl5 (5.0 patchlevel 5 subversion 3) configuration​:
  Platform​:
  osname=hpux, osvers=10.20, archname=PA-RISC1.1
  uname='hp-ux mongo b.10.20 u 9000800 245239331 unlimited-user license '
  hint=recommended, useposix=true, d_sigaction=define
  usethreads=undef useperlio=undef d_sfio=undef
  Compiler​:
  cc='cc', optimize=' ', gccversion=
  cppflags='-Ae -DDEBUGGING -I/usr/local/include'
  ccflags ='-Ae -DDEBUGGING -I/usr/local/include'
  stdchar='unsigned char', d_stdstdio=define, usevfork=false
  intsize=4, longsize=4, ptrsize=4, doublesize=8
  d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
  alignbytes=8, usemymalloc=y, prototype=define
  Linker and Libraries​:
  ld='ld', ldflags =' -L/usr/local/lib'
  libpth=/usr/local/lib /lib/pa1.1 /lib /usr/lib /usr/ccs/lib
  libs=-lnsl_s -lndbm -ldld -lm -lc -lndir -lcrypt
  libc=/lib/libc.sl, so=sl, useshrplib=false, libperl=libperl.a
  Dynamic Linking​:
  dlsrc=dl_hpux.xs, dlext=sl, d_dlsymun=undef, ccdlflags='-Wl,-E
-Wl,-B,deferred '
  cccdlflags='+z', lddlflags='-b -L/usr/local/lib'

Locally applied patches​:
 


@​INC for perl 5.00503​:
  /home/dougw/perl/lib/5.00503/PA-RISC1.1
  /home/dougw/perl/lib/5.00503
  /home/dougw/perl/lib/site_perl/5.005/PA-RISC1.1
  /home/dougw/perl/lib/site_perl/5.005
  .


Environment for perl 5.00503​:
  HOME=/home/dougw
  LANG (unset)
  LANGUAGE (unset)
  LD_LIBRARY_PATH (unset)
  LOGDIR (unset)

PATH=/home/dougw/bin​:/home/dougw/perl/bin​:/usr/bin​:/opt/ansic/bin​:/usr/ccs/b
in​:/usr/contrib/bin​:/opt/nettladm/bin​:/opt/pd/bin​:/usr/bin/X11​:/usr/contrib/
bin/X11​:/opt/upgrade/bin​:/opt/perf/bin​:/opt/hpnp//bin​:/opt/dtcmgr/sbin​:/opt/
hparray/bin​:/opt/rdtcmgr/sbin​:/bin​:/opt/langtools/bin​:/opt/imake/bin​:/opt/pr
ed/bin​:/opt/ignite/bin​:/opt/resmon/bin​:/usr/bin​:/usr/ccs/bin​:/usr/contrib/bi
n​:/opt/nettladm/bin​:/usr/bin/X11​:/usr/contrib/bin/X11​:/opt/upgrade/bin​:/opt/
hpnp/bin​:/usr/local/bin​:/opt/perl5/bin​:/scope/cvs/cvsroot/bin​:/opt/fourgen73
1/bin​:/opt/informix730/bin​:/scope/dev/all.4gm/lib.4gs​:/scope/dev/scripts​:.
  PERL_BADLANG (unset)
  SHELL=/usr/bin/sh

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Jan 22, 2000

From [Unknown Contact. See original ticket]

At 16​:07 -0800 2000-01-21, Doug Wilson wrote​:

A non zero status is returned from the
system() function when the supplied command
begins with an environment variable setting
where the environment variable contains an
underscore or a digit.

It's not HP-specific, or 5.005_03-specific. Here's a one-line fix.
It's against 5.005_03, as that's what the report's against, but also
applies to 5.005_63 (with an offset of 184 lines).

Inline Patch
--- perl5.005_03/doio.c-as_received	Sat Mar 27 17:57:24 1999
+++ perl5.005_03/doio.c	Sat Jan 22 18:10:15 2000
@@ -1069,7 +1069,7 @@ do_exec(char *cmd)
      if (strnEQ(cmd,"exec",4) && isSPACE(cmd[4]))
  	goto doshell;

-    for (s = cmd; *s && isALPHA(*s); s++) ;	/* catch VAR=val gizmo */
+    for (s = cmd; *s && isALNUM_LC(*s); s++) ;	/* catch VAR=val gizmo */
      if (*s == '=')
  	goto doshell;


-- 

Dominic Dunlop

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Jan 22, 2000

From [Unknown Contact. See original ticket]

Dominic Dunlop writes​:

At 16​:07 -0800 2000-01-21, Doug Wilson wrote​:

A non zero status is returned from the
system() function when the supplied command
begins with an environment variable setting
where the environment variable contains an
underscore or a digit.

It's not HP-specific, or 5.005_03-specific. Here's a one-line fix.
It's against 5.005_03, as that's what the report's against, but also
applies to 5.005_63 (with an offset of 184 lines).

--- perl5.005_03/doio.c-as_received Sat Mar 27 17​:57​:24 1999
+++ perl5.005_03/doio.c Sat Jan 22 18​:10​:15 2000
@​@​ -1069,7 +1069,7 @​@​ do_exec(char *cmd)
if (strnEQ(cmd,"exec",4) && isSPACE(cmd[4]))
goto doshell;

- for (s = cmd; *s && isALPHA(*s); s++) ; /* catch VAR=val gizmo */
+ for (s = cmd; *s && isALNUM_LC(*s); s++) ; /* catch VAR=val gizmo */
if (*s == '=')
goto doshell;

Is not LC locale? Then this is not a fix (set LANG=C), and is a very
dangerous modification (putting locale-dependencies in the core
operation). What about isWORD (sp?)?

Ilya

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Jan 23, 2000

From [Unknown Contact. See original ticket]

At 13​:21 -0500 2000-01-22, Ilya Zakharevich wrote​:

Dominic Dunlop writes​:

--- perl5.005_03/doio.c-as_received Sat Mar 27 17​:57​:24 1999
+++ perl5.005_03/doio.c Sat Jan 22 18​:10​:15 2000
@​@​ -1069,7 +1069,7 @​@​ do_exec(char *cmd)
if (strnEQ(cmd,"exec",4) && isSPACE(cmd[4]))
goto doshell;

- for (s = cmd; *s && isALPHA(*s); s++) ; /* catch
VAR=val gizmo */
+ for (s = cmd; *s && isALNUM_LC(*s); s++) ; /* catch
VAR=val gizmo */
if (*s == '=')
goto doshell;

Is not LC locale? Then this is not a fix (set LANG=C), and is a very
dangerous modification (putting locale-dependencies in the core
operation). What about isWORD (sp?)?

Good point. There's not an isWORD(), but plain isALNUM() seems to
suit, so I should have said​:

Inline Patch
--- perl5.005_03/doio.c-as_received	Sat Mar 27 17:57:24 1999
+++ perl5.005_03/doio.c	Sat Jan 22 18:10:15 2000
@@ -1069,7 +1069,7 @@ do_exec(char *cmd)
      if (strnEQ(cmd,"exec",4) && isSPACE(cmd[4]))
  	goto doshell;

-    for (s = cmd; *s && isALPHA(*s); s++) ;	/* catch VAR=val gizmo */
+    for (s = cmd; *s && isALNUM(*s); s++) ;	/* catch VAR=val gizmo */
      if (*s == '=')
  	goto doshell;


-- 

Dominic Dunlop

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Jan 24, 2000

From [Unknown Contact. See original ticket]

At 22​:58 +0100 2000-01-23, Dominic Dunlop wrote​:

--- perl5.005_03/doio.c-as_received Sat Mar 27 17​:57​:24 1999
+++ perl5.005_03/doio.c Sat Jan 22 18​:10​:15 2000
@​@​ -1069,7 +1069,7 @​@​ do_exec(char *cmd)
if (strnEQ(cmd,"exec",4) && isSPACE(cmd[4]))
goto doshell;

- for (s = cmd; *s && isALPHA(*s); s++) ; /* catch VAR=val gizmo */
+ for (s = cmd; *s && isALNUM(*s); s++) ; /* catch VAR=val gizmo */
if (*s == '=')
goto doshell;

Here's the corresponding test. Again, against 5.005_03, but also
applies against 5.005_63 with an offset of 9 lines.

Inline Patch
--- perl5.005_03/t/op/exec.t-as_received	Fri Aug  7 01:02:14 1998
+++ perl5.005_03/t/op/exec.t	Mon Jan 24 10:08:32 2000
@@ -11,7 +11,7 @@
      exit(0);
  }

-print "1..8\n";
+print "1..10\n";

  if ($^O ne 'os2') {
    print "not ok 1\n" if system "echo ok \\1";	# shell interpreted
@@ -32,4 +32,11 @@

  unless (exec "lskdjfalksdjfdjfkls") {print "ok 7\n";} else {print 
"not ok 7\n";}

-exec "echo","ok","8";
+# make sure shell is used if shell variable assignment seen
+print "not ok 8\n" if system "s_1=bfzky echo ok 8";
+
+# apparent assignment after command name should not pull in shell
+# (test assumes there's no executable called "set" around)
+print "not " unless system "set s_1=bfzky"; print "ok 9\n";
+
+exec "echo","ok","10";

--
Dominic Dunlop

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.