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

split function broken on MacOS #9050

Closed
p5pRT opened this issue Oct 4, 2007 · 20 comments
Closed

split function broken on MacOS #9050

p5pRT opened this issue Oct 4, 2007 · 20 comments

Comments

@p5pRT
Copy link

p5pRT commented Oct 4, 2007

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

Searchable as RT46073$

@p5pRT
Copy link
Author

p5pRT commented Oct 4, 2007

From erict@etmac.local

Created by erict@etmac.local

This is a bug report for perl from erict@​etmac.local,
generated with the help of perlbug 1.35 running under perl v5.8.8.

-----------------------------------------------------------------
The split function fails to work properly on MacOS 10.4.10, either using the
builtin perl (v5.8.6) or v5.8.8 from the MacPorts project (which I'm using to
run perlbug.

For example, running this command

perl -e 'print join("​:", split(/ */, "hi there"));'

produces no output on MacOS, but produces

h​:i​:t​:h​:e​:r​:e

as expected with perl v5.8.8 on Ubuntu 7.04

I could create a simpler example, but this is sort of canonical, and
it's in the documentation for the split function.

Perl Info

Flags:
    category=core
    severity=high

Site configuration information for perl v5.8.8:

Configured by erict at Wed Feb 21 15:49:49 EST 2007.

Summary of my perl5 (revision 5 version 8 subversion 8) configuration:
  Platform:
    osname=darwin, osvers=8.8.2, archname=darwin-2level
    uname='darwin etmac.local 8.8.2 darwin kernel version 8.8.2: thu sep 28 20:43:26 pdt 2006; root:xnu-792.14.14.obj~1release_i386 i386 i386 '
    config_args='-des -Dprefix=/opt/local -Dccflags=-I'/opt/local/include' -Dldflags=-L/opt/local/lib -Dvendorprefix=/opt/local -Dcc=/usr/bin/gcc-4.0'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='/usr/bin/gcc-4.0', ccflags ='-I/opt/local/include -fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/opt/local/include',
    optimize='-O3',
    cppflags='-no-cpp-precomp -I/opt/local/include -fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/opt/local/include'
    ccversion='', gccversion='4.0.1 (Apple Computer, Inc. build 5367)', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='env MACOSX_DEPLOYMENT_TARGET=10.3 cc', ldflags ='-L/opt/local/lib'
    libpth=/opt/local/lib /usr/lib
    libs=-ldbm -ldl -lm -lc
    perllibs=-ldl -lm -lc
    libc=/usr/lib/libc.dylib, so=dylib, useshrplib=false, libperl=libperl.a
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' '
    cccdlflags=' ', lddlflags='-L/opt/local/lib -bundle -undefined dynamic_lookup'

Locally applied patches:
    


@INC for perl v5.8.8:
    /opt/local/lib/perl5/5.8.8/darwin-2level
    /opt/local/lib/perl5/5.8.8
    /opt/local/lib/perl5/site_perl/5.8.8/darwin-2level
    /opt/local/lib/perl5/site_perl/5.8.8
    /opt/local/lib/perl5/site_perl
    /opt/local/lib/perl5/vendor_perl/5.8.8/darwin-2level
    /opt/local/lib/perl5/vendor_perl/5.8.8
    /opt/local/lib/perl5/vendor_perl
    .


Environment for perl v5.8.8:
    DYLD_LIBRARY_PATH (unset)
    HOME=/Users/erict
    LANG=en_US.UTF-8
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/opt/local/bin:/opt/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin
    PERL_BADLANG (unset)
    SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Oct 5, 2007

From shouldbedomo@mac.com

On 2007–10–05, at 01​:54, erict@​etmac.local (via RT) wrote​:

The split function fails to work properly on MacOS 10.4.10, either
using the
builtin perl (v5.8.6) or v5.8.8 from the MacPorts project (which
I'm using to
run perlbug.

For example, running this command

perl -e 'print join("​:", split(/ */, "hi there"));'

produces no output on MacOS,

Looks like a documentation error to me​: the output is produced, but
you don't see it because there's no line-end sequence. It seems that
the Terminal app does not display output in this situation. (Neither
does xterm, as shipped by Apple -- I don't have any other terminal
emulators around to try.)

perl -le 'print join("​:", split(/ */, "hi there"));'

lets you see it, as does

perl -e 'print join("​:", split(/ */, "hi there"));' | od -c

but produces

h​:i​:t​:h​:e​:r​:e

as expected with perl v5.8.8 on Ubuntu 7.04

I'd expect it to produce

h​:i​:t​:h​:e​:r​:eYourPS1Prompt$

Is that what happens?

Sorry I don't have time to dash off a doc patch just now. Will do it
later if nobody steps into the breach.
--
Dominic Dunlop

@p5pRT
Copy link
Author

p5pRT commented Oct 5, 2007

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

@p5pRT
Copy link
Author

p5pRT commented Oct 5, 2007

From @JohnPeacock

erict@​etmac.local (via RT) wrote​:

For example, running this command

perl -e 'print join("​:", split(/ */, "hi there"));'

produces no output on MacOS, but produces

Out of curiousity, can you replicate command?

$ perl -MO=Deparse -e 'print join("​:", split(/ */, "hi there"));'
print join('​:', split(/ */, 'hi there', 0));
-e syntax OK

I'm just trying to confirm that there isn't some weird shell interaction (yes, I
know those single quotes should protect the bare asterisk).

John

@p5pRT
Copy link
Author

p5pRT commented Oct 5, 2007

From @eserte

On 2007?10?05, at 01​:54, erict@​etmac.local (via RT) wrote​:

The split function fails to work properly on MacOS 10.4.10, either
using the
builtin perl (v5.8.6) or v5.8.8 from the MacPorts project (which
I'm using to
run perlbug.

For example, running this command

perl -e 'print join("​:", split(/ */, "hi there"));'

produces no output on MacOS,

Looks like a documentation error to me​: the output is produced, but
you don't see it because there's no line-end sequence. It seems that
the Terminal app does not display output in this situation. (Neither
does xterm, as shipped by Apple -- I don't have any other terminal
emulators around to try.)

I don't think it's a terminal issue, and it's even not a shell issue. It's
just the way how the shell prompt is created. In zsh, you can set the
prompt to make sure it starts at the beginning of a line​:

  PROMPT="^M> "

(The ^M is a literal \r, typed in with Ctrl-V Ctrl-M)

If I set the prompt like this, then it seems that the perl oneliner
without the -l switch does not output anything. However, without the ^M
it works like expected.

It is my impression that some default shell resource files have similar
mechanisms in their prompts.

Regards,
  Slaven

@p5pRT
Copy link
Author

p5pRT commented Oct 5, 2007

From jos@dwim.org

On 05 Oct 2007, at 01​:54, erict@​etmac.local (via RT) wrote​:

-----------------------------------------------------------------
The split function fails to work properly on MacOS 10.4.10, either
using the
builtin perl (v5.8.6) or v5.8.8 from the MacPorts project (which
I'm using to
run perlbug.

For example, running this command

perl -e 'print join("​:", split(/ */, "hi there"));'

produces no output on MacOS, but produces

h​:i​:t​:h​:e​:r​:e

as expected with perl v5.8.8 on Ubuntu 7.04

I could create a simpler example, but this is sort of canonical, and
it's in the documentation for the split function.

$ perl -le 'print join("​:", split(/ */, "hi there"));'
h​:i​:t​:h​:e​:r​:e

$ uname -a
Darwin coke 8.10.1 Darwin Kernel Version 8.10.1​: Wed May 23 16​:33​:00
PDT 2007; root​:xnu-792.22.5~1/RELEASE_I386 i386 i386

Site configuration information for perl v5.8.8​:

Default perl version 10.4.10 is currently 5.8.6, which makes me think
you've compiled your own perl and did something 'special' with it,
although it's not immediately obvious to me from the configure args.

For me, both the stock perl and my own compiled 5.8.8 work as expected,
as you can see above.

Configured by erict at Wed Feb 21 15​:49​:49 EST 2007.

Summary of my perl5 (revision 5 version 8 subversion 8) configuration​:
Platform​:
osname=darwin, osvers=8.8.2, archname=darwin-2level
uname='darwin etmac.local 8.8.2 darwin kernel version 8.8.2​:
thu sep 28 20​:43​:26 pdt 2006; root​:xnu-792.14.14.obj~1release_i386
i386 i386 '
config_args='-des -Dprefix=/opt/local -Dccflags=-I'/opt/local/
include' -Dldflags=-L/opt/local/lib -Dvendorprefix=/opt/local -Dcc=/
usr/bin/gcc-4.0'
hint=recommended, useposix=true, d_sigaction=define
usethreads=undef use5005threads=undef useithreads=undef
usemultiplicity=undef
useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
use64bitint=undef use64bitall=undef uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler​:
cc='/usr/bin/gcc-4.0', ccflags ='-I/opt/local/include -fno-
common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -pipe -
Wdeclaration-after-statement -I/opt/local/include',
optimize='-O3',
cppflags='-no-cpp-precomp -I/opt/local/include -fno-common -
DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -pipe -
Wdeclaration-after-statement -I/opt/local/include'
ccversion='', gccversion='4.0.1 (Apple Computer, Inc. build
5367)', gccosandvers=''
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
d_longlong=define, longlongsize=8, d_longdbl=define,
longdblsize=16
ivtype='long', ivsize=4, nvtype='double', nvsize=8,
Off_t='off_t', lseeksize=8
alignbytes=8, prototype=define
Linker and Libraries​:
ld='env MACOSX_DEPLOYMENT_TARGET=10.3 cc', ldflags ='-L/opt/
local/lib'
libpth=/opt/local/lib /usr/lib
libs=-ldbm -ldl -lm -lc
perllibs=-ldl -lm -lc
libc=/usr/lib/libc.dylib, so=dylib, useshrplib=false,
libperl=libperl.a
gnulibc_version=''
Dynamic Linking​:
dlsrc=dl_dlopen.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' '
cccdlflags=' ', lddlflags='-L/opt/local/lib -bundle -undefined
dynamic_lookup'

Locally applied patches​:

---
@​INC for perl v5.8.8​:
/opt/local/lib/perl5/5.8.8/darwin-2level
/opt/local/lib/perl5/5.8.8
/opt/local/lib/perl5/site_perl/5.8.8/darwin-2level
/opt/local/lib/perl5/site_perl/5.8.8
/opt/local/lib/perl5/site_perl
/opt/local/lib/perl5/vendor_perl/5.8.8/darwin-2level
/opt/local/lib/perl5/vendor_perl/5.8.8
/opt/local/lib/perl5/vendor_perl
.

---
Environment for perl v5.8.8​:
DYLD_LIBRARY_PATH (unset)
HOME=/Users/erict
LANG=en_US.UTF-8
LANGUAGE (unset)
LD_LIBRARY_PATH (unset)
LOGDIR (unset)
PATH=/opt/local/bin​:/opt/local/sbin​:/bin​:/sbin​:/usr/bin​:/usr/sbin
PERL_BADLANG (unset)
SHELL=/bin/bash

--

  Jos Boumans

  How do I prove I'm not crazy to people who are?

@p5pRT
Copy link
Author

p5pRT commented Oct 5, 2007

From shouldbedomo@mac.com

On 2007–10–05, at 13​:52, slaven@​rezic.de wrote​:

I don't think it's a terminal issue, and it's even not a shell
issue. It's
just the way how the shell prompt is created. In zsh, you can set the
prompt to make sure it starts at the beginning of a line​:

PROMPT="^M> "

(The ^M is a literal \r, typed in with Ctrl-V Ctrl-M)

If I set the prompt like this, then it seems that the perl oneliner
without the -l switch does not output anything. However, without
the ^M
it works like expected.

It is my impression that some default shell resource files have
similar
mechanisms in their prompts.

Thanks for that clarification. Anyway, the promised doc patch is
attached. Frankly, it makes perlfunc POD uglier, but it should
guarantee that cutting and pasting the examples into one-liners (not
an unreasonable thing to do) always behaves as expected.
--
Dominic Dunlop

@p5pRT
Copy link
Author

p5pRT commented Oct 5, 2007

@p5pRT
Copy link
Author

p5pRT commented Oct 5, 2007

From @Tux

On Fri, 5 Oct 2007 16​:20​:30 +0200, Dominic Dunlop <shouldbedomo@​mac.com>
wrote​:

On 2007–10–05, at 13​:52, slaven@​rezic.de wrote​:

I don't think it's a terminal issue, and it's even not a shell
issue. It's
just the way how the shell prompt is created. In zsh, you can set the
prompt to make sure it starts at the beginning of a line​:

PROMPT="^M> "

(The ^M is a literal \r, typed in with Ctrl-V Ctrl-M)

If I set the prompt like this, then it seems that the perl oneliner
without the -l switch does not output anything. However, without
the ^M
it works like expected.

It is my impression that some default shell resource files have
similar
mechanisms in their prompts.

Thanks for that clarification. Anyway, the promised doc patch is
attached. Frankly, it makes perlfunc POD uglier, but it should
guarantee that cutting and pasting the examples into one-liners (not
an unreasonable thing to do) always behaves as expected.

You made it too ugly imho

- print join('​:', split(/ */, 'hi there'));
+ print(join('​:', split(/ */, 'hi there')), "\n");
* print join('​:', split(/ */, 'hi there'), "\n");

--
H.Merijn Brand Amsterdam Perl Mongers (http​://amsterdam.pm.org/)
using & porting perl 5.6.2, 5.8.x, 5.9.x on HP-UX 10.20, 11.00, 11.11,
& 11.23, SuSE 10.0 & 10.2, AIX 4.3 & 5.2, and Cygwin. http​://qa.perl.org
http​://mirrors.develooper.com/hpux/ http​://www.test-smoke.org
  http​://www.goldmark.org/jeff/stupid-disclaimers/

@p5pRT
Copy link
Author

p5pRT commented Oct 5, 2007

From shouldbedomo@mac.com

On 2007–10–05, at 16​:43, H.Merijn Brand wrote​:

You made it too ugly imho

- print join('​:', split(/ */, 'hi there'));
+ print(join('​:', split(/ */, 'hi there')), "\n");
* print join('​:', split(/ */, 'hi there'), "\n");

But that produces slightly different output​:

$ perl
print join('​:', split(/ */, 'hi there'), "\n");
h​:i​:t​:h​:e​:r​:e​:
$ perl
print(join('​:', split(/ */, 'hi there')), "\n");
h​:i​:t​:h​:e​:r​:e

--
Dominic Dunlop

@p5pRT
Copy link
Author

p5pRT commented Oct 5, 2007

From @tamias

On Fri, Oct 05, 2007 at 02​:43​:18PM +0000, H.Merijn Brand wrote​:

You made it too ugly imho

- print join('​:', split(/ */, 'hi there'));
+ print(join('​:', split(/ */, 'hi there')), "\n");
* print join('​:', split(/ */, 'hi there'), "\n");

Should be​:

print join('​:', split(/ */, 'hi there')), "\n";

Ronald

@p5pRT
Copy link
Author

p5pRT commented Oct 6, 2007

From shouldbedomo@mac.com

On 2007–10–05, at 16​:59, Ronald J Kimball wrote​:

On Fri, Oct 05, 2007 at 02​:43​:18PM +0000, H.Merijn Brand wrote​:

You made it too ugly imho

- print join('​:', split(/ */, 'hi there'));
+ print(join('​:', split(/ */, 'hi there')), "\n");
* print join('​:', split(/ */, 'hi there'), "\n");

Should be​:

print join('​:', split(/ */, 'hi there')), "\n";

Revised, less uglifying, version of patch attached.
--
Dominic Dunlop

@p5pRT
Copy link
Author

p5pRT commented Oct 6, 2007

@p5pRT
Copy link
Author

p5pRT commented Oct 16, 2007

From @schwern

erict@​etmac.local (via RT) wrote​:

The split function fails to work properly on MacOS 10.4.10, either using the
builtin perl (v5.8.6) or v5.8.8 from the MacPorts project (which I'm using to
run perlbug.

I cannot reproduce this problem on OS X 10.4.10 using Terminal and either
Apple's shipped Perl or my own built 5.8.8 or MacPorts' perl.

Could you show us the output of "env"?

--
Stabbing you in the face so you don't have to.

@p5pRT
Copy link
Author

p5pRT commented Oct 16, 2007

From @schwern

Dominic Dunlop wrote​:

On 2007–10–05, at 16​:59, Ronald J Kimball wrote​:

On Fri, Oct 05, 2007 at 02​:43​:18PM +0000, H.Merijn Brand wrote​:

You made it too ugly imho

- print join('​:', split(/ */, 'hi there'));
+ print(join('​:', split(/ */, 'hi there')), "\n");
* print join('​:', split(/ */, 'hi there'), "\n");

Should be​:

print join('​:', split(/ */, 'hi there')), "\n";

Revised, less uglifying, version of patch attached.

Maybe it should use say?

--
Whip me, beat me, make my code compatible with VMS!

@p5pRT
Copy link
Author

p5pRT commented Oct 16, 2007

From @ap

Hi Dominic,

* Dominic Dunlop <shouldbedomo@​mac.com> [2007-10-05 17​:00]​:

On 2007–10–05, at 16​:43, H.Merijn Brand wrote​:

You made it too ugly imho

- print join('​:', split(/ */, 'hi there'));
+ print(join('​:', split(/ */, 'hi there')), "\n");
* print join('​:', split(/ */, 'hi there'), "\n");

But that produces slightly different output​:

$ perl
print join('​:', split(/ */, 'hi there'), "\n");
h​:i​:t​:h​:e​:r​:e​:
$ perl
print(join('​:', split(/ */, 'hi there')), "\n");
h​:i​:t​:h​:e​:r​:e

FWIW I always write this sort of thing as

  print join( ... ) . "\n"

instead. No subtleties to remember. I also generally omit parens
on `split`, so that’d be

  print join('​:', split / */, 'hi there') . "\n";

Much easier to read off, IMO.

--
*AUTOLOAD=*_;sub _{s/(.*)​::(.*)/print$2,(",$\/"," ")[defined wantarray]/e;$1}
&Just->another->Perl->hack;
#Aristotle

@p5pRT
Copy link
Author

p5pRT commented Apr 27, 2008

From p5p@perl.wizbit.be

Adds a "\n" in the examples of split.

The attached patch (or at least one similar) was submitted before but
never applied.
Was there a particular reason?

The original bug report/patches (from October 2007)​:
http​://rt.perl.org/rt3/Public/Bug/Display.html?id=46073

Kind regards,

Bram

@p5pRT
Copy link
Author

p5pRT commented Apr 27, 2008

@p5pRT
Copy link
Author

p5pRT commented Apr 27, 2008

From @rgs

2008/4/27 Bram <p5p@​perl.wizbit.be>​:

Adds a "\n" in the examples of split.

Thanks, applied.

@p5pRT
Copy link
Author

p5pRT commented Apr 27, 2008

@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
Projects
None yet
Development

No branches or pull requests

1 participant