Bug #114
closedreplace true(1) and false(1) with simple shell scripts
0%
Description
Hi.
The following diffs are replacing true(1) and false(1) with
simple shell scripts because there is no need for more.
http://leaf.dragonflybsd.org/~robert/false.diff
http://leaf.dragonflybsd.org/~robert/true.diff
Updated by corecode almost 19 years ago
On 18.03.2006, at 23:14, Robert Nagy wrote:
The following diffs are replacing true(1) and false(1) with
simple shell scripts because there is no need for more.http://leaf.dragonflybsd.org/~robert/false.diff
http://leaf.dragonflybsd.org/~robert/true.diff
I wonder why the guys as CSRG/FreeBSD didn't use shell scripts for
that. I guess they must have had a reason. I doubt it's about speed,
but who knows.
What's the gain in having those as shell scripts?
cheers
simon
Updated by maciejej almost 19 years ago
On Sun, 2006-03-19 at 00:54 +0100, Simon 'corecode' Schubert wrote:
On 18.03.2006, at 23:14, Robert Nagy wrote:
The following diffs are replacing true(1) and false(1) with
simple shell scripts because there is no need for more.http://leaf.dragonflybsd.org/~robert/false.diff
http://leaf.dragonflybsd.org/~robert/true.diffI wonder why the guys as CSRG/FreeBSD didn't use shell scripts for
that. I guess they must have had a reason. I doubt it's about speed,
but who knows.
I checked other *NIX distros. NetBSD and OpenBSD use shell scripts,
Solaris uses C but with _exit() before the return statement, and GNU
uses a C program, but I haven't checked the source.
Updated by dacut almost 19 years ago
Jake Maciejewski wrote:
I checked other *NIX distros. NetBSD and OpenBSD use shell scripts,
Solaris uses C but with _exit() before the return statement, and GNU
uses a C program, but I haven't checked the source.
Well, as long as we're bikeshedding and optimizing the pointless... ;-)
% cat true.s
.text
.globl _start
.type _start, @function
_start:
pushl $0
pushl $0
movl $1, %eax
int $0x80
% cat false.s
.text
.globl _start
.type _start, @function
_start:
pushl $1
pushl $0
movl $1, %eax
int $0x80
Updated by pavalos almost 19 years ago
On Sat, Mar 18, 2006 at 11:26:55PM -0800, David Cuthbert wrote:
Jake Maciejewski wrote:
I checked other *NIX distros. NetBSD and OpenBSD use shell scripts,
Solaris uses C but with _exit() before the return statement, and GNU
uses a C program, but I haven't checked the source.Well, as long as we're bikeshedding and optimizing the pointless... ;-)
% cat true.s
.text
.globl _start
.type _start, @function_start:
pushl $0
pushl $0
movl $1, %eax
int $0x80% cat false.s
.text
.globl _start
.type _start, @function_start:
pushl $1
pushl $0
movl $1, %eax
int $0x80
Lose the whitespace, color it green, and we have ourselves an
improvement!
Updated by maciejej almost 19 years ago
I'm perfectly happy with the current C versions. I was just reporting
what everyone else is doing. If we really want to go nuts, we could
assemble the ELF executables as a raw binaries like in
http://www.muppetlabs.com/~breadbox/software/tiny/teensy.html
Updated by check+iwffwl00rsbt4y47 almost 19 years ago
Robert Nagy <robert@bsd.hu> wrote:
> The following diffs are replacing true(1) and false(1) with
> simple shell scripts because there is no need for more.
I fail to see the advantage of replacing the binaries
with shell-scripts.
However, I really don't care much, as long as true(1) and
false(1) are still available as shell-builtins in /bin/sh.
If those builtins are to be removed then I will complain
loudly. :-)
Best regards
Oliver
Updated by dillon almost 19 years ago
We are going to stick with the C version. There is no reason to nerf
the performance of the programs even if one assumes that they will
hardly ever be used in a time-critical situation. It certainly isn't
worth the byte-savings for the files since they are already only
3280 bytes each.
Neither do we need to adopt _exit() vs exit(), or link statically, or
play any other tricks which have no clear benefit. The performance is
just fine as it.
-Matt
Matthew Dillon
<dillon@backplane.com>
Updated by dacut almost 19 years ago
Matthew Dillon wrote:
We are going to stick with the C version. There is no reason to nerf
the performance of the programs even if one assumes that they will
hardly ever be used in a time-critical situation. It certainly isn't
worth the byte-savings for the files since they are already only
3280 bytes each.
But the assembly versions allow the following loop to run in half the time:
while true; do done;
;-)