But why? Looking at the wordexp synopsis it doesn't seem like a particularly advanced function. Why don't the various libc's just implement this function directly in C?
The macOS libc is the FreeBSD libc. FreeBSD is upstream.
FreeBSD changed it recently to use /bin/sh instead of /usr/bin/perl, because it's a bit smaller and faster.
Turns out this is actually documented in the manpage for wordexp()! (And refers to the mentioned fact that it now calls 'sh' directly.)
> BUGS
> Do not pass untrusted user data to wordexp(), regardless of whether the WRDE_NOCMD flag is set. The wordexp() function attempts to detect input that would cause commands to be executed before passing it to the shell but it does not use the same parser so it may be fooled.
> The current wordexp() implementation does not recognize multibyte characters, since the shell (which it invokes to perform expansions) does not.
/* This function computes the expansion rate of spacetime. This version contains an additional factor that causes it to accelerate to allow for rapid testing of other aspects of the physics engine. This MUST be removed before the production release or spacetime will accelerate forever and experience heat death instead of reaching steady state. -God */
Now I see why you can't change /usr/bin on macos. actually there is both perl5 and python2.7 in /usr/bin, libc does have a choice (that is if the tweet is true)...
You can’t change use/bin because that’s a common malware attack vector.
It also has the nice effect of forcing user installed utilities to install in the /local/ variants (which user build projects should be doing on Linux iirc), so an OS update doesn’t overwrite user data.
That's essentially what the OG tweet is saying: Pinnacle of software development: you can solve the problem with three lines of Perl, but you don’t, because of a non-argument against Perl. Since there didn't used to be that many arguments against perl/Perl it worked its way into a lot of systems even if it wasn't actually implementing the system.
Of course Perl, having fallen out of vogue, probably wouldn't be used today but it used to be everywhere so its footprint is still pretty large.
Also - I can't help but see the irony in shelling out to perl given experienced Perl developers always tell the less experienced ones to avoid shelling out from Perl if possible and to only do that as a last resort if there isn't an existing library to solve the problem.
Not exactly related to the link but apparently the author of that tweet blocked me. I don’t recall having ever had any interactions with them. Is there a way to contact that person and figure out why? I have no idea what I did and I’m quite puzzled.
There is a good chance they subscribe to a blocklist, so you could be blocked by anyone of a thousand people. Image the old PGP web of trust, but for crafting perfect echo chambers. I wonder if anybody has ever done the math on that.
You find out someone has blocked you, and your instinct is to communicate with them? The specific thing they have explicitly disallowed? I'd reconsider this, and just move on.
[+] [-] coldtea|7 years ago|reply
[+] [-] self_awareness|7 years ago|reply
https://code.woboq.org/userspace/glibc/posix/wordexp.c.html
[+] [-] w0utert|7 years ago|reply
[+] [-] rurban|7 years ago|reply
[+] [-] MichaelMoser123|7 years ago|reply
[+] [-] fouronnes3|7 years ago|reply
[+] [-] self_awareness|7 years ago|reply
http://xr.anadoxin.org/source/xref/macos-10.14-mojave/Libc-1...
The 'perl' code was a part of Libc v825.24, which seems to be included between 10.7 (Lion) and 10.8 (Mountain Lion).
Of course I still find it hilarious that even the old code did that!
[+] [-] opencl|7 years ago|reply
[+] [-] panic|7 years ago|reply
[+] [-] josteink|7 years ago|reply
It should use Emacs instead.
[+] [-] protomyth|7 years ago|reply
[+] [-] fouronnes3|7 years ago|reply
[+] [-] detaro|7 years ago|reply
[+] [-] jslabovitz|7 years ago|reply
> BUGS
> Do not pass untrusted user data to wordexp(), regardless of whether the WRDE_NOCMD flag is set. The wordexp() function attempts to detect input that would cause commands to be executed before passing it to the shell but it does not use the same parser so it may be fooled.
> The current wordexp() implementation does not recognize multibyte characters, since the shell (which it invokes to perform expansions) does not.
[+] [-] senozhatsky|7 years ago|reply
[+] [-] api|7 years ago|reply
[+] [-] acura|7 years ago|reply
[+] [-] MichaelMoser123|7 years ago|reply
https://en.wikipedia.org/wiki/System_Integrity_Protection
[+] [-] olliej|7 years ago|reply
It also has the nice effect of forcing user installed utilities to install in the /local/ variants (which user build projects should be doing on Linux iirc), so an OS update doesn’t overwrite user data.
[+] [-] fit2rule|7 years ago|reply
[+] [-] leejo|7 years ago|reply
Of course Perl, having fallen out of vogue, probably wouldn't be used today but it used to be everywhere so its footprint is still pretty large.
Also - I can't help but see the irony in shelling out to perl given experienced Perl developers always tell the less experienced ones to avoid shelling out from Perl if possible and to only do that as a last resort if there isn't an existing library to solve the problem.
[+] [-] the_mitsuhiko|7 years ago|reply
[+] [-] woodman|7 years ago|reply
[+] [-] stonogo|7 years ago|reply
[+] [-] unknown|7 years ago|reply
[deleted]
[+] [-] acura|7 years ago|reply
So how well does it reflect reality?
[+] [-] raimue|7 years ago|reply
This repository is just a snapshot that somebody else prepared and uploaded to GitHub, but apparently it is not maintained.
[+] [-] unknown|7 years ago|reply
[deleted]