Live data from Hacker News

Apple's libc shells out to Perl to implement wordexp

github.com

31–40 of 49 posts

Re: Apple's libc shells out to Perl to implement wordexp

#31
post #13
post #3

Well, you are warned: /* XXX this is _not_ designed to be fast */

Performance is the least of my worries here. I'd be more worried about security, and plain dependency management. I mean, let's say this libc thing is supposed to be installed in quite a lot of systems, are we really sure that perl thing is installed in all of those systems? And what if, by some crazy coincidence, perl happens to depend on libc?

> I mean, let's say this libc thing is supposed to be installed in quite a lot of systems

Apple's libc is not an independent thing to them - it's a part of OSX and iOS. You're not supposed to be able to take it out and use it for other things.

Re: Apple's libc shells out to Perl to implement wordexp

#32
post #18
post #17

Earlier quoted context omitted.

The current one is a derivative of NetBSD's implementation (where it shells out to use a sh builtin)

Judging by both the source code and its placement in the repository (gen/FreeBSD/wordexp.c), I'm thinking it's a derivative of the FreeBSD implementation (which may itself be a derivative of the NetBSD implementation, or perhaps the other way around).

Yes, the OSX code seems to come from FreeBSD. Here is the FreeBSD version of the source:

https://github.com/freebsd/freebsd/blob/master/lib/libc/gen/...

It looks very similar to the current OSX file posted in an earlier comment. Calls /bin/sh too.

Re: Apple's libc shells out to Perl to implement wordexp

#33
post #26
post #20

Earlier quoted context omitted.

Almost everything depends on perl. Unless you're running a very small embedded setup, you'll have extremely hard time living without perl. Circular dependencies are perfectly normal.

I'm aware that a lot of projects use perl for the build. But on runtime? I doubt it.

Are you on a Debian based OS? Try

  aptitude search '~i~Dperl'

Re: Apple's libc shells out to Perl to implement wordexp

#34

Sorry, I don't have a Mac to check, but does the OSX build of Perl depend on libc? Also, that code seems to be from 2008 (or at least that's the latest year in the copyright header) despite the commit being from 2012. Does anyone know if this has been updated? Inserting a NUL byte between each word, and at the end doesn't sound like it requires Perl...

> otool -L /usr/bin/perl /usr/bin/perl: /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1151.14.0) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1213.0.0)

Thanks, much appreciated.

I thought there may be some strange cyclic dependency going on, but it seems not.

Re: Apple's libc shells out to Perl to implement wordexp

#35
post #5

As it's already written in the manual... http://linux.die.net/man/3/wordexp wordexp, wordfree - perform word expansion like a posix-shell So, the implementer decided to take the short route, and just spawn a shell which, essentially, gets passed the input data to wordexp(), to do the work. But, of course, having something that starts with such a comment... /* XXX this is _not_ designed to be fast (...) wordexp is als…

Is wordexp() a requiement for being POSIX compatible?

I searched through the FreeBSD repo on Gitbub and the only references to wordexp is basically the code itself. Searching the whole Github does not show many things either.

How common is the function in practice and how important is it?

Re: Apple's libc shells out to Perl to implement wordexp

#36
post #13

Earlier quoted context omitted.

Performance is the least of my worries here. I'd be more worried about security, and plain dependency management. I mean, let's say this libc thing is supposed to be installed in quite a lot of systems, are we really sure that perl thing is installed in all of those systems? And what if, by some crazy coincidence, perl happens to depend on libc?

> I mean, let's say this libc thing is supposed to be installed in quite a lot of systems Apple's libc is not an independent thing to them - it's a part of OSX and iOS. You're not supposed to be able to take it out and use it for other things.

Fair enough.

Re: Apple's libc shells out to Perl to implement wordexp

#37
post #21
post #7

Earlier quoted context omitted.

> sometimes you have to get shit done And Apple have always been masters in selling polished, nicely packages shit as the most advanced technology ever conceived.

With respect, is there evidence to support your claim? My direct experience is that I have received value far in excess of what I have had to pay for the Apple products and services I have purchased over the years. For example, I'm typing this reply on my PowerBook, which I use all day, every day in my work. I also have my iPhone with me constantly, and use it heavily. Finally, the Apple brand was said to be worth ab…

OT, but you're still using a Powerbook? That's pretty impressive. Which generation\year was it? I'm guessing you've had to swap out batteries and upgrade hard drive - have you had to modify anything else?

Re: Apple's libc shells out to Perl to implement wordexp

#38
post #5

As it's already written in the manual... http://linux.die.net/man/3/wordexp wordexp, wordfree - perform word expansion like a posix-shell So, the implementer decided to take the short route, and just spawn a shell which, essentially, gets passed the input data to wordexp(), to do the work. But, of course, having something that starts with such a comment... /* XXX this is _not_ designed to be fast (...) wordexp is als…

Is wordexp() a requiement for being POSIX compatible? I searched through the FreeBSD repo on Gitbub and the only references to wordexp is basically the code itself. Searching the whole Github does not show many things either. How common is the function in practice and how important is it?

requirement? yes. http://pubs.opengroup.org/onlinepubs/9699919799/functions/wo...

common in practice? openbsd doesn't support it. afaik few programs use it, and those that do are usually easily patched not to (can use glob instead or disable whatever feature entirely).

Re: Apple's libc shells out to Perl to implement wordexp

#39
post #23
post #17

Earlier quoted context omitted.

The current one is a derivative of NetBSD's implementation (where it shells out to use a sh builtin)

License-wise: - this piece of code is 2BSD-licensed - it calls out to /bin/sh - on OS X, /bin/sh is hardlinked to /bin/bash - OS X's bash is GPLv2 Forking to shell is the only way to reuse bash's code. More often than not I really wish sh were not bash .

"Forking to shell is the only way to reuse bash's code."

well, the other obvius way is to license this piece of code as GPLv2.

Re: Apple's libc shells out to Perl to implement wordexp

#40
post #37
post #21

Earlier quoted context omitted.

With respect, is there evidence to support your claim? My direct experience is that I have received value far in excess of what I have had to pay for the Apple products and services I have purchased over the years. For example, I'm typing this reply on my PowerBook, which I use all day, every day in my work. I also have my iPhone with me constantly, and use it heavily. Finally, the Apple brand was said to be worth ab…

OT, but you're still using a Powerbook? That's pretty impressive. Which generation\year was it? I'm guessing you've had to swap out batteries and upgrade hard drive - have you had to modify anything else?

Sorry, my mistake. It's a mid-2012 MacBook Pro. 16GB DDR and 512GB SSD.

http://support.apple.com/kb/SP694

Post reply on HN