From owner-freebsd-hackers@FreeBSD.ORG Sun Jun 26 08:27:16 2005 Return-Path: X-Original-To: hackers@freebsd.org Delivered-To: freebsd-hackers@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 97DF716A41C for ; Sun, 26 Jun 2005 08:27:16 +0000 (GMT) (envelope-from vd@datamax.bg) Received: from jengal.datamax.bg (jengal.datamax.bg [82.103.104.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0BD3443D4C for ; Sun, 26 Jun 2005 08:27:05 +0000 (GMT) (envelope-from vd@datamax.bg) Received: from sinanica.bg.datamax (sinanica.bg.datamax [192.168.10.1]) by jengal.datamax.bg (Postfix) with QMQP id 4976687CA for ; Sun, 26 Jun 2005 11:27:02 +0300 (EEST) Received: (nullmailer pid 77045 invoked by uid 1004); Sun, 26 Jun 2005 08:27:02 -0000 Date: Sun, 26 Jun 2005 11:27:02 +0300 From: Vasil Dimov To: hackers@freebsd.org Message-ID: <20050626082702.GA76984@sinanica.bg.datamax> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; x-action=pgp-signed Content-Disposition: inline X-OS: FreeBSD 5.4-STABLE User-Agent: Mutt/1.5.9i Cc: Subject: /bin/sh -e function parsing strangeness X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: vd@datamax.bg List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 26 Jun 2005 08:27:16 -0000 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Can anyone explain this: % sh -ec 'f() { return 5 ; } ; if f ; then echo tt ; else echo ff ; fi' ff % sh -ec 'f() { return 5 ; : ; } ; if f ; then echo tt ; else echo ff ; fi' % echo $? 5 If any commands appear after the return statement in a function, then -e flag triggers untested command failure although function call is tested with `if' statement. -----BEGIN PGP SIGNATURE----- iD8DBQFCvmbWFw6SP/bBpCARAo2GAJ9DT0FeeUEbweidCklxj8V8uEeXHQCgmNd7 pT2zbB8UF9TClhRUWpyZyf4= =Alpo -----END PGP SIGNATURE-----