Project

General

Profile

Actions

Bug #114

closed

replace true(1) and false(1) with simple shell scripts

Added by robert about 18 years ago. Updated over 17 years ago.

Status:
Closed
Priority:
Low
Assignee:
-
Category:
-
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:

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

Actions #1

Updated by corecode about 18 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

Actions #2

Updated by maciejej about 18 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.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.

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.

Actions #3

Updated by dacut about 18 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

Actions #4

Updated by pavalos about 18 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!

Actions #5

Updated by maciejej about 18 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

Actions #6

Updated by check+iwffwl00rsbt4y47 about 18 years ago

Robert Nagy <> 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

Actions #7

Updated by dillon about 18 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
&lt;&gt;
Actions #8

Updated by dacut about 18 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;

;-)

Actions

Also available in: Atom PDF