tobold.org

correct • elegant • free

△ comp.unix.shell △

◅ find without subdirs

How can sourced script determine own name? ▻

Bourne sh: Execute Command in "if" Condition and Negate Return Value?

In article <8fd42l$ih8$1@nnrp1.deja.com>,
Hon-Chi Ng  <honchi_ng@my-deja.com> wrote:
>Basically, I'm looking for the valid Bourne shell syntax with the
>semantic similar to
>
>  if ! $my_exec; then

The usual way to do this is to use the null command, `:'.

    if $my_exec -v; then
            :
    else
            echo $my_exec corrupt 1>&2
    fi

>BTW, I know other scripting languages like Perl has better syntax to
>achieve it, but I refer to stay with Bourne shell if possible.

Oh well.  In rc, you can say this.

    if (! $my_exec -v) {
            echo $my_exec corrupt >[1=2]
    }

Tim.
--
Tim Goodwin   | "If you don't know what closures are, you probably don't
Leicester, UK | want to know what closures are." -- Larry Wall

Original headers:

From: tjg@star.le.ac.uk (Tim Goodwin)
Newsgroups: comp.unix.shell,comp.unix.admin,comp.unix.questions
Subject: Re: Bourne sh: Execute Command in "if" Condition and Negate Return Value?
Date: 11 May 2000 11:27:25 +0100
Message-ID: <8fe1v3$ao0$1@ltpcg.star.le.ac.uk>
References: <8fd42l$ih8$1@nnrp1.deja.com>

△ comp.unix.shell △

◅ find without subdirs

How can sourced script determine own name? ▻