Re: RFC: etcupdate tool in base?

From: John Baldwin <jhb_at_freebsd.org>
Date: Tue, 3 Aug 2010 13:46:55 -0400
On Tuesday, June 15, 2010 6:31:45 am Dag-Erling Smørgrav wrote:
> Garrett Cooper <yanefbsd_at_gmail.com> writes:
> > 1. Script doesn't check to see whether or not it has write access (and
> > doesn't catch some errors):
> 
> IMHO, any shell script which is intended to be used more than twice
> should start with "set -e".

It turns out that this can be quite a PITA to workaround if you have commands 
that don't fail, but return "status".  I use a shell function which uses $? to 
return an enum of the result of comparing two files.  Using -e for that 
requires many odd workarounds.  A better case is diff(1).  I use diff(1) to 
generate diff output for 'etcupdate diff' so you can generate a patch of your 
local changes to etc.  However, diff returns $? of 1 if it detects a 
difference which is not a failure, but sh -e treats as a failure.  This would 
require gross hacks along the line of "|| true" or some such which obfuscate 
the code.

-- 
John Baldwin
Received on Tue Aug 03 2010 - 17:39:49 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:05 UTC