Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 23 May 2008 17:35:23 +0200 (CEST)
From:      Oliver Fromme <olli@lurza.secnetix.de>
To:        freebsd-questions@FreeBSD.ORG, pauls@utdallas.edu
Subject:   Re: Shell scripting - suppressing and eliminating error messages
Message-ID:  <200805231535.m4NFZNu2024533@lurza.secnetix.de>
In-Reply-To: <A4CB71AD0CF555F6A68D3B27@utd65257.utdallas.edu>

next in thread | previous in thread | raw e-mail | index | archive | help
Paul Schmehl wrote:
 > --On Tuesday, May 20, 2008 17:36:26 -0500 Paul Schmehl <pauls@utdallas.edu> 
 > wrote:
 > > if ( ${BATCH} ); then
 > > [...]
 > > 1: not found
 > 
 > Never mind....forgot to use [ ] for test instead of ( ).

If the value of $BATCH is always either 0 and 1, a neat
trick is to define two shell functions:

0() { false; }
1() { true; }

Then you can savely write:

if ( $BATCH ); then

Or even:

if $BATCH; then

Best regards
   Oliver

-- 
Oliver Fromme, secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing b. M.
Handelsregister: Registergericht Muenchen, HRA 74606,  Geschäftsfuehrung:
secnetix Verwaltungsgesellsch. mbH, Handelsregister: Registergericht Mün-
chen, HRB 125758,  Geschäftsführer: Maik Bachmann, Olaf Erb, Ralf Gebhart

FreeBSD-Dienstleistungen, -Produkte und mehr:  http://www.secnetix.de/bsd

"Clear perl code is better than unclear awk code; but NOTHING
comes close to unclear perl code"  (taken from comp.lang.awk FAQ)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200805231535.m4NFZNu2024533>