3 ms·
No you make this script: #!/bin/sh exec /bin/busybox cmp And place it at /usr/bin/cmp
by sophacles 2y ago
No you make this script:
#!/bin/sh
exec /bin/busybox cmp
And place it at /usr/bin/cmp
- teddyh 2y agoSurely you mean #!/bin/sh exec /bin/busybox cmp "$@"
- oguz-ismail 2y ago`#!/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.
- teddyh 2y agoIf /bin/sh does not exist, what in the world is executing the shell script?
- oguz-ismail 2y agoThe shell, of course. It just might not be (because it doesn't have to be) located in /bin.
- teddyh 2y agoI’m pretty sure that /bin/sh is mandated by POSIX.
- oguz-ismail 2y agoIt's not. See https://pubs.opengroup.org/onlinepubs/9799919799/utilities/sh.html#tag_20_110_16 https://pubs.opengroup.org/onlinepubs/9799919799/utilities/s... Applications should note that the standard PATH to the shell cannot be assumed to be either /bin/sh or /usr/bin/sh, and should be determined by interrogation of the PATH returned by getconf PATH, ensuring that the returned pathname is an absolute pathname and not a shell built-in.
- alerighi 2y agoSo 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.
- sophacles 2y agoYou'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.