Hacker News new | ask | show | jobs
by blenderob 661 days ago
What about compiled binaries that for one reason or another is doing an execve() on "/usr/bin/cmp" or some such thing? Do you propose changing every script and every binary on earth that expects Busybox to be a POSIXy, Unixy environment?
2 comments

On Unixes it doesn't matter if /usr/bin/cmp is a script or a compiled binary. If the script has correct shebang, kernel takes care of executing it.
Shebangs are not part of the UNIX specification. What happens if an executable starts with `#!' is implementation-defined.
UNIX/POSIX doesn't specify an executable format at all
is being able to run busybox part of that specification? Linux ELF files are tagged for Linux OS, not generic Unix OS.
> is being able to run busybox part of that specification?

It's the other way round. This is like asking if running RHEL is part of the specification? Obviously not. But RHEL provides an environment that is quite close to the specification.

So is running a busybox part of the specification? Obviously not. But Busybox provides an environment that is close to the speficiation.

Then it would be busybox's responsibility to make busybox work.
No you make this script:

   #!/bin/sh
   exec /bin/busybox cmp
And place it at /usr/bin/cmp
Surely you mean

  #!/bin/sh
  exec /bin/busybox cmp "$@"
`#!/bin/sh' makes this less portable than it could be, if /bin/sh doesn't exists on my system it won't work, for example. Remove that line and it'll work everywhere.
If /bin/sh does not exist, what in the world is executing the shell script?
The shell, of course. It just might not be (because it doesn't have to be) located in /bin.
I’m pretty sure that /bin/sh is mandated by POSIX.
So now to execute a program that could have been a direct run you have to fire up a shell, have it parse the file, and execute the instruction? Not really a great thing...

Plus, you have to know the absolute path of the executable busybox, not something you always know in advance.

You're not wrong about the extra execution of shell, although a lightweight shell like ash or dash doesn't have a huge overhead.

But realistically, the only people that need to worry about the actual location of the busybox executable are the people who write the install script - it would take that as an argument or variable and spit out all the little scripts as an automated process. The current installer already has to do most of this work as part of setting up the relevant links anyway.