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

open bug #1852

Closed
p5pRT opened this issue Apr 18, 2000 · 2 comments
Closed

open bug #1852

p5pRT opened this issue Apr 18, 2000 · 2 comments

Comments

@p5pRT
Copy link

p5pRT commented Apr 18, 2000

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

Searchable as RT3115$

@p5pRT
Copy link
Author

p5pRT commented Apr 18, 2000

From Norman.Azadian@swisscom.com

If the first characters of an open filename specification are whitespace,
the open fails without yielding a failure status. As I understand the first
two sentences of the 2nd paragraph on page 191 of the camel book, this
should not be the case. Here's a small program to illustrate the problem​:

  #!/usr/bin/perl -w
  #Illustrates a perl bug
  #According to the second paragraph on page 191 of the bible, leading
  #whitespace should not be a problem. Here it is shown to be.

  open OUTPUT, " | cat " || die;
  print OUTPUT "THIS LINE DOES NOT APPEAR\n";
  close OUTPUT;

  open OUTPUT, "| cat " || die;
  print OUTPUT "THIS LINE DOES APPEAR\n";
  close OUTPUT;

  exit 0;

Running this program yields (for me)​:

  print on closed filehandle main​::OUTPUT at pt.pl line 7.
  THIS LINE DOES APPEAR

Here's the output of my 'perl -V'​:

  Summary of my perl5 (5.0 patchlevel 5 subversion 3) configuration​:
  Platform​:
  osname=hpux, osvers=11.00, archname=PA-RISC2.0
  uname='hp-ux sbe1351 b.11.00 e 9000889 274894302 8-user license
'
  hint=previous, useposix=true, d_sigaction=define
  usethreads=undef useperlio=undef d_sfio=undef
  Compiler​:
  cc='cc', optimize='-O', gccversion=
  cppflags='-D_HPUX_SOURCE -Aa +DA2.0W'
  ccflags ='-D_HPUX_SOURCE -Aa +DA2.0W'
  stdchar='unsigned char', d_stdstdio=define, usevfork=false
  intsize=4, longsize=8, ptrsize=8, doublesize=8
  d_longlong=undef, longlongsize=, d_longdbl=define,
longdblsize=16
  alignbytes=8, usemymalloc=y, prototype=define
  Linker and Libraries​:
  ld='ld', ldflags ='+DA2.0W'
  libpth=/usr/lib/pa20_64
  libs=-lnsl -lgdbm -ldl -ldld -lm -lc
  libc=/usr/lib/pa20_64/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'

  Characteristics of this binary (from libperl)​:
  Built under hpux
  Compiled at Feb 9 2000 11​:41​:29
  %ENV​:
 
PERLLIB="/mbc/mbc509/mbc509/lib/perl​:/mbc/mbc509/mbc509/lib/perl/PA-RISC2.0"
  @​INC​:
  /mbc/mbc509/mbc509/lib/perl
  /mbc/mbc509/mbc509/lib/perl/PA-RISC2.0
  /usr/local/perl5/lib/5.00503/PA-RISC2.0
  /usr/local/perl5/lib/5.00503
  /usr/local/perl5/lib/site_perl/5.005/PA-RISC2.0
  /usr/local/perl5/lib/site_perl/5.005
  .

NHA
Norman.Azadian@​Swisscom.com

@p5pRT
Copy link
Author

p5pRT commented Apr 18, 2000

From @pudge

At 13.14 +0200 2000.04.18, Norman.Azadian@​swisscom.com wrote​:

If the first characters of an open filename specification are whitespace,
the open fails without yielding a failure status.

No, it fails just fine, if you check it just fine.

As I understand the first
two sentences of the 2nd paragraph on page 191 of the camel book, this
should not be the case.

I think you are correct. The Camel says that first whitespace is stripped,
then the filename is checked, so according to that description, " | cat "
and "| cat" should be treated exactly the same. The question is whether or
not the Camel is correct in what Perl's behavior should be. I dunno.

open OUTPUT, " | cat " || die;

You are saying​:

  open OUTPUT, (" | cat " || die);

since " | cat" is always true, you will never die. You did read part of
page 191 in the Camel, but apparently not the admonition to use "or die"
instead of "|| die". :-)

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