[PATCH]: Make rc sh-compatible.
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. -- ~predatorfreak GnuPG Public key: http://pred.dcaf-security.org/dcafsec-pub-gpgkey.asc
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. -- Anton Vorontsov email: cbou@mail.ru backup email: ya-cbou@yandex.ru irc://irc.freenode.net/bd2
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
On 20:01 Tue 09 Oct?, Brett Goulder wrote:
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.
Just to put things 100% straight: 1. I said I and prologic played with it a while ago and didn't get the echo stuff to behave as "the origial" without resorting to /bin/echo. That's all. 2. It was dash, not mksh. :) cheers //treach
_______________________________________________ CRUX mailing list CRUX@lists.crux.nu http://lists.crux.nu/mailman/listinfo/crux
-- Don't take life too seriously; you'll never get out of it alive. - Elbert Hubbard
On Wed, 10 Oct 2007 03:07:50 +0200 treach wrote:
On 20:01 Tue 09 Oct?, Brett Goulder wrote:
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.
Just to put things 100% straight:
1. I said I and prologic played with it a while ago and didn't get the echo stuff to behave as "the origial" without resorting to /bin/echo. That's all.
2. It was dash, not mksh. :)
cheers
//treach
_______________________________________________ CRUX mailing list CRUX@lists.crux.nu http://lists.crux.nu/mailman/listinfo/crux
Ahh sorry, I thought to meant that echo was somehow broken, misunderstanding. I also assuming that because the person talking about it before us mentioned mksh, that you were using the same. Sorry about that. -- ~predatorfreak GnuPG Public key: http://pred.dcaf-security.org/dcafsec-pub-gpgkey.asc
On Wed, 2007-10-10 at 03:07 +0200, treach wrote:
On 20:01 Tue 09 Oct?, Brett Goulder wrote:
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.
Just to put things 100% straight:
1. I said I and prologic played with it a while ago and didn't get the echo stuff to behave as "the origial" without resorting to /bin/echo. That's all.
Would it be an option to call /bin/echo only when it behaves differently from built-in echo, i.e. in the "echo -n" cases i presume?
On Tue, 2007-10-09 at 17:14 -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.
The "cmd &> file" redirection is also a bash-ism that should be replaced with "cmd > file 2>&1" (used at least in the services start loop)
On Tue, 9 Oct 2007 17:14:38 -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.
This implements Mark's suggested change for echo behaviour, changes the top #!/bin/bash to #!/bin/sh for all the files and fixes the bits that I missed when going over it the first time. -- ~predatorfreak GnuPG Public key: http://pred.dcaf-security.org/dcafsec-pub-gpgkey.asc
Hi there Brett how are you? How would u suggest implementing this patch in a Pkgmk file? On 15/10/2007, Brett Goulder <predatorfreak@dcaf-security.org> wrote:
On Tue, 9 Oct 2007 17:14:38 -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.
This implements Mark's suggested change for echo behaviour, changes the top #!/bin/bash to #!/bin/sh for all the files and fixes the bits that I missed when going over it the first time.
-- ~predatorfreak GnuPG Public key: http://pred.dcaf-security.org/dcafsec-pub-gpgkey.asc
_______________________________________________ CRUX mailing list CRUX@lists.crux.nu http://lists.crux.nu/mailman/listinfo/crux
participants (5)
-
Anton Vorontsov
-
Brett Goulder
-
Mark Rosenstand
-
Ross Cameron
-
treach