[Toybox] [PATCH] toybox compiled on OS X 10.6
Georgi Chorbadzhiyski
gf at unixsol.org
Tue Mar 13 00:59:56 PDT 2012
On 13.3.2012 г. 07:10, Rob Landley wrote:
> Patch #0001:
>
> In the short term, create a directory with a symlink from "sed" to the
> gsed binary, and insert it at the start of your $PATH.
>
> In the longer term: I plan to add sed to toybox, and the ability to
> build individual commands standalone. I'd like to make toybox build
> its' own sed standalone, and use that.
>
> (I was going to say "test the host sed to see if it's good enough"...
> but why test? Build the toybox one, use the toybox one. No different
> than building our own instlist binary during install. (Because toybox
> is a target binary so you can't do "./toybox --list" when cross
> compiling, that's why.)
That sounds good.
> patch #0002:
>
> I agree with this in principle, but look at the first hunk:
>
> --- a/lib/lib.c
> +++ b/lib/lib.c
> @@ -800,7 +800,7 @@ int yesno(char *prompt, int def)
> for (i=0; i<3&& !isatty(i); i++);
> if (i == 3) return 1;
>
> - fdprintf(i, "%s (%c/%c):", prompt, def ? 'Y' : 'y', def ? 'n' :
> 'N');
> + fprintf(stderr, "%s (%c/%c):", prompt, def ? 'Y' : 'y', def ?
> 'n' : 'N');
> while (read(i,&buf, 1)) {
>
> In the fdprintf, "i" can be 0, 1, or 2. You're hardwiring it to 2,
> which is not the same behavior. (With filehandles it's easy to loop
> through stdin, stdout, and stderr. With FILE *, not so much.)
>
> It's possible that the _correct_ behavior here is to look at the
> controlling tty, ala fopen("/dev/tty"), which assumes you've got a fully
> populated /dev (not always the case) but I think we can live with that.
> (Sigh. When I get back into toysh I'm going to have to refamiliarize
> myself with all the controlling terminal details. getsid(), getpgrp(),
> tcgetpgrp(), and so on...)
>
> Still, it's not quite the drop-in replacement you're making it, code
> that uses thsi stuff has to change from file descripter to FILE *, which
> impacts get_line() as well. A later hunk breaks patch (TT.fileout is
> never actually stdout, it's the new file we're creating with patches
> applied).
I have seen yesno() implementations that test if stdin isatty() and
use stdin reading and stderr for writing. If stdin is not a tty just
return confirmation.
> patch #0004:
>
> I don't want to sprinkle #ifdef linux into toys/*.c.
>
> If we can add some kidn of portability/apple directory with alternate
> implementations of stuff, or put really clever macros into
> lib/portability.h, I'm all for it. If we can't,
>
> More to the point: I'm all for making commands work on the macintosh,
> but this doesn't. This stubs them out. I'd much rather just disable
> them in the config (the way unshare vanishes on systems that don't
> support it: you can't select it, the option goes away when the build
> environment can't compile it) than produce a misleading NOP command.
Oh the ifdefs were just a quick hack to get toybox to build. I've done
the same when compiled it on android. Definitely genconfig.sh should
just disable the applets that are not working on the platform.
> 0006 if you could investigate why posix-2008 functions don't work on
> macosx that would be nice. It seems like they _should_, I'd like to
> understand why they don't before trying to replace them.
I'll into that today.
--
Georgi Chorbadzhiyski
http://georgi.unixsol.org/
1331625596.0
More information about the Toybox
mailing list