![](https://secure.gravatar.com/avatar/5b0355767dcb0ac7cbe371bcefc4ee4e.jpg?s=120&d=mm&r=g)
On Wed, 10 Oct 2007 02:19:36 +0400 Anton Vorontsov wrote:
On Tue, Oct 09, 2007 at 05:14:38PM -0400, Brett Goulder wrote:
I know it was brought up for 2.4 and reading over the logs for the devel meeting, I saw that the conses was "wait until someone else does it", more or less.
Well, I actually wound up doing it last night, attached is a patch against rc with the discussed and approved changes to move syslog handling, making rc sh-compatible. [...] -echo "The system is coming down. Please wait." +/bin/echo "The system is coming down. Please wait."
~$ cat rc-make-sh-compatible-1.diff | grep /bin/echo | wc -l 20
~$ time echo test test
real 0m0.000s user 0m0.000s sys 0m0.000s
~$ time /bin/echo test test
real 0m0.003s user 0m0.000s sys 0m0.003s
~$ time for i in `seq 1 1000`; do echo a > /dev/null; done
real 0m0.051s user 0m0.043s sys 0m0.010s
~$ time for i in `seq 1 1000`; do /bin/echo a > /dev/null; done
real 0m2.374s user 0m0.770s sys 0m1.607s
/bin/echo is much slower (ratio 2374/51, i.e ~46/1).
~$ strace /bin/echo test 2>&1 | wc -l 37
37 * 20 = 740
Thus, if all rc.* echoes executed: 740 system calls if /bin/echo used vs. 20 system calls (just write()s) if built-in echoes used. (ratio 37/1)
Yeah, this is may be a silly comparison, there is not that much echoes in the rc.* scripts...
But why you've made echo->/bin/echo transition in the first place? Is $PATH empty at that stage? Maybe just fill it? /bin/sh with out built-in will use /bin/echo from the $PATH, and /bin/sh with built-in will use built-in.
Plus I don't get the whole idea anyway: bash is just yet another tool, why not use its features? It's in core/ anyway, it's also must-have for the vast amount of scripts with bashisms, you can't just throw it away. If you can't... isn't it wise to use bash where it suits better?
...I'm neither for nor against bashisms though, just curious.
I did this because there seems to be an interest in converting the rc scripts to be sh-compatible and I had the time. I moved everything to /bin/echo because treach had told me that in order for it to work properly with mksh, it required it to directly call /bin/echo, I'm not certain if that's true or not, but I didn't want to take the chance. -- ~predatorfreak GnuPG Public key: http://pred.dcaf-security.org/dcafsec-pub-gpgkey.asc