Project

General

Profile

« Previous | Next » 

Revision 14762

fix: lib/sh/util.sh: already_exists_msg(): changed calling convention to avoid it seeming like `return 0` is run if already_exists_msg() throws an error, when in fact already_exists_msg() is just a command that should be run before returning/errexiting

View differences:

util.sh
1291 1291

  
1292 1292
#### commands
1293 1293

  
1294
already_exists_msg() # usage: cond || what=... already_exists_msg || return 0
1294
already_exists_msg()
1295
# usage: cond || { save_e; what=_ already_exists_msg; rethrow; } || return 0
1295 1296
{
1296
	save_e # needed because $(mk_hint) resets $?
1297
	type=info die "$what already exists, skipping
1297
	log_info "$what already exists, skipping
1298 1298
$(mk_hint 'to force-remake, prepend `rm=1` to the command')"
1299 1299
}
1300 1300

  
1301 1301
require_not_exists() # usage: require_not_exists file || return 0
1302
{ test ! -e "$1" || what="file \"$1\"" already_exists_msg; }
1302
{ test ! -e "$1" || { save_e; what="file \"$1\"" already_exists_msg; rethrow;} }
1303 1303

  
1304 1304
function to_file() # usage: stdout=... [if_not_exists=1] [del=] to_file cmd...
1305 1305
# auto-removes a command's output file on error (like make's .DELETE_ON_ERROR)

Also available in: Unified diff