Path: csiph.com!optima2.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!usenet.stanford.edu!not-for-mail From: Greg Wooledge Newsgroups: gnu.bash.bug Subject: Re: assert built-in Date: Wed, 19 Aug 2015 11:48:26 -0400 Lines: 21 Approved: bug-bash@gnu.org Message-ID: References: NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: usenet.stanford.edu 1439999314 27996 208.118.235.17 (19 Aug 2015 15:48:34 GMT) X-Complaints-To: action@cs.stanford.edu Cc: bug-bash@gnu.org To: Craig Envelope-to: bug-bash@gnu.org Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.3i X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 139.137.100.1 X-BeenThere: bug-bash@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Bug reports for the GNU Bourne Again SHell List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com gnu.bash.bug:11398 On Wed, Aug 19, 2015 at 08:39:15AM +0000, Craig wrote: > It's somewhat cumbersome to have to transport this assert function from > project to project, so it would save a considerable amount of effort and > time if it were built-in. > function assert() { > local lineno=${BASH_LINENO[0]} \ > src=${BASH_SOURCE[1]} \ > lines=() > > mapfile -n 1 -t -s $(( $lineno - 1 )) lines < "$src" > > printf "ASSERT: ${src##*/}:$lineno: %s\n" "$lines" > > exit 1 > } I don't think there will be broad enough interest to justify bloating bash with a feature that can be achieved with a 4-line function. But I only speak for myself, not for Chet.