Perl / perl5

🐪 The Perl programming language
https://dev.perl.org/perl5/
Other
1.98k stars 559 forks source link

eof(STDIN);eof(STDIN) behave differently on cygwin perl #5144

Open p5pRT opened 22 years ago

p5pRT commented 22 years ago

Migrated from rt.perl.org#8691 (status was 'open')

Searchable as RT8691$

p5pRT commented 22 years ago

From tagunov@motor.ru

This is a bug report for perl from "Anton Tagunov" \tagunov@​motor\.ru\, generated with the help of perlbug 1.33 running under perl v5.6.1.


perl -e "eof(STDIN);eof(STDIN)"

behaves differently on cygwin perl and on regular windows perl and on linux perls​:

on cygwin it is enough to press control-D once before the script completes\,

on other perls one has to press control-D (unix)/ control-Z\,\ (windows) twice.

Looks like cygwin variant caches the "EOF" status for the terminal. Would be beneficial to have this uniform on all the platforms.

To me Cygwin's behavior is more appealing\, but I'm not sure if it is along Perl traditions :-) (The man says that 'Terminals may loose eof() status if you do').

This is what "Nicholas Clark" \nick@​unfortu\.net has written on this topic in a msg to the [ID 20020222.011] bug​: NC> ... cache "EOF"-ness on a perl handle connected to a tty\, NC> and only actually try to read more if perl program does NC> an explicit read

May be it would be no harm to cache the "EOF"-ness even for regular files too?

Or should the cygwin version be deprived of this useful feature and make it behave as other perls do?



Flags​:   category=core   severity=medium


Site configuration information for perl v5.6.1​:

Configured by Fifer at Thu Dec 21 21​:37​:10 2000.

Summary of my perl5 (revision 5.0 version 6 subversion 1) configuration​:   Platform​:   osname=cygwin\, osvers=1.1.6(0.3032)\, archname=cygwin   uname='cygwin_nt-5.0 fifer 1.1.6(0.3032) 2000-11-21 21​:00 i686 unknown '   config_args='-de'   hint=recommended\, useposix=true\, d_sigaction=define   usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef   useperlio=undef d_sfio=undef uselargefiles=define usesocks=undef   use64bitint=undef use64bitall=undef uselongdouble=undef   Compiler​:   cc='gcc'\, ccflags ='-DPERL_USE_SAFE_PUTENV -DHAS_SBRK_PROTO -fno-strict-aliasing'\,   optimize='-O2'\,   cppflags='-DPERL_USE_SAFE_PUTENV -DHAS_SBRK_PROTO -fno-strict-aliasing'   ccversion=''\, gccversion='2.95.2-5 19991024 (cygwin experimental)'\, gccosandvers=''   intsize=4\, longsize=4\, ptrsize=4\, doublesize=8\, byteorder=1234   d_longlong=define\, longlongsize=8\, d_longdbl=define\, longdblsize=12   ivtype='long'\, ivsize=4\, nvtype='double'\, nvsize=8\, Off_t='off_t'\, lseeksize=4   alignbytes=8\, usemymalloc=y\, prototype=define   Linker and Libraries​:   ld='ld2'\, ldflags =' -s -L/usr/local/lib'   libpth=/usr/local/lib /usr/lib /lib   libs=-lgdbm -lcrypt   perllibs=-lcrypt   libc=/usr/lib/libc.a\, so=dll\, useshrplib=true\, libperl=libperl5_6_1.a   Dynamic Linking​:   dlsrc=dl_dlopen.xs\, dlext=dll\, d_dlsymun=undef\, ccdlflags=' -s'   cccdlflags=' '\, lddlflags=' -s -L/usr/local/lib'

Locally applied patches​:   v5.6.1-TRIAL1


@​INC for perl v5.6.1​:   /usr/lib/perl5/5.6.1/cygwin   /usr/lib/perl5/5.6.1   /usr/lib/perl5/site_perl/5.6.1/cygwin   /usr/lib/perl5/site_perl/5.6.1   /usr/lib/perl5/site_perl   .


Environment for perl v5.6.1​:   HOME=/cygdrive/c   LANG (unset)   LANGUAGE (unset)   LC_ALL=EN_US   LD_LIBRARY_PATH (unset)   LOGDIR (unset)   PATH=/usr/local/bin​:/usr/bin​:/bin​:/home/anthony/mnt/apps/ibm/vaj/eab/bin​:/cygdrive/c/usr/local/bin/​:/home/anthony/mnt/Program Files/ibm/gsk5/lib​:/home/anthony/mnt/APPS/ROSE/RATION~1/NUTCROOT/bin​:/home/anthony/mnt/APPS/ROSE/RATION~1/NUTCROOT/bin/x11​:/home/anthony/mnt/APPS/ROSE/RATION~1/NUTCROOT/mksnt​:/mnt/java/bin​:/home/anthony/mnt/apps/vbroker/jre/Bin​:/home/anthony/mnt/apps/vbroker/Bin​:/cygdrive/c/WINNT/system32​:/cygdrive/c/WINNT​:/cygdrive/c/program files/util​:/home/anthony/mnt/apps/CacheSys/Bin​:/cygdrive/c/Program Files/rksupport​:/cygdrive/c/WINNT/ton/bin​:/home/anthony/mnt/apps/rose/common​:/home/anthony/mnt/apps/rose/Rational Test​:/home/anthony/mnt/apps/borland/delphi/Bin​:/home/anthony/mnt/apps/borland/delphi/Projects/Bpl​:/home/anthony/mnt/apps/ibm/IBM/IMNNQ​:/home/anthony/mnt/apps/ibm/db2p/BIN​:/home/anthony/mnt/apps/ibm/db2p/FUNCTION​:/home/anthony/mnt/apps/ibm/db2p/SAMPLES/REPL​:/home/anthony/mnt/apps/ibm/db2p/HELP​:/home/anthony/mnt/apps/ibm/websphere/bin   PERL_BADLANG (unset)   SHELL=/bin/sh

p5pRT commented 22 years ago

From [Unknown Contact. See original ticket]

Anton Tagunov wrote​:

This is a bug report for perl from "Anton Tagunov" \tagunov@​motor\.ru\, generated with the help of perlbug 1.33 running under perl v5.6.1.

----------------------------------------------------------------- perl -e "eof(STDIN);eof(STDIN)"

behaves differently on cygwin perl and on regular windows perl and on linux perls​:

on cygwin it is enough to press control-D once before the script completes\,

on other perls one has to press control-D (unix)/ control-Z\,\ (windows) twice.

Looks like cygwin variant caches the "EOF" status for the terminal. Would be beneficial to have this uniform on all the platforms.

To me Cygwin's behavior is more appealing\, but I'm not sure if it is along Perl traditions :-) (The man says that 'Terminals may loose eof() status if you do').

This is what "Nicholas Clark" \nick@​unfortu\.net has written on this topic in a msg to the [ID 20020222.011] bug​: NC> ... cache "EOF"-ness on a perl handle connected to a tty\, NC> and only actually try to read more if perl program does NC> an explicit read

May be it would be no harm to cache the "EOF"-ness even for regular files too?

Or should the cygwin version be deprived of this useful feature and make it behave as other perls do?

The only problem with caching EOF-ness on non-ttys is that it might cause problems when we try to implement something like 'tail -f' ...

OTOH\, if we were to clear the cached EOF-ness whenever seek is called\, that would be sufficient to make this 'correct'\, since there's stuff in the "tail -f" FAQ which says a seek might be necessary... so there's no harm in *making* it necessary.

-- print reverse( "\,rekcah"\, " lreP"\, " rehtona"\, " tsuJ" )."\n";