Project

General

Profile

« Previous | Next » 

Revision 9026

lib/sh/util.sh: renamed save_e () to save_e_cmd () since it actually runs a command, in addition to saving $?

View differences:

lib/sh/util.sh
51 51
fi # load new aliases
52 52
if self_being_included; then
53 53

  
54
# usage: save_e cmd... || { use $e (or $?); rethrow; }
55
function save_e () { "$@"; e=$?; rethrow; } # rethrow because e= clears $?
56
alias save_e='declare e; save_e ' # last space alias-expands next word
54
# usage: save_e_cmd cmd... || { use $e (or $?); rethrow; }
55
function save_e_cmd () { "$@"; e=$?; rethrow; } # rethrow because e= clears $?
56
alias save_e_cmd='declare e; save_e_cmd ' # last space alias-expands next word
57 57

  
58 58
function log_e () # usage: log_e cmd... [ || use $e (or $?) ]
59 59
{
......
68 68

  
69 69
# usage: try cmd...; ignore status; if catch status; then ...; fi; end_try
70 70

  
71
function try () { "save_e" "$@" || true; }
71
function try () { "save_e_cmd" "$@" || true; }
72 72
alias try='declare e; try ' # last space alias-expands next word
73 73

  
74 74
catch () { test "$e" -eq "$1"; e=0; }
......
99 99
let () { builtin let "$@" || true; }
100 100
	# "If the last ARG evaluates to 0, let returns 1" (`help let`)
101 101

  
102
bool2int () { save_e test -z "$1"; echo "$e"; } # empty->0; non-empty->1
102
bool2int () { save_e_cmd test -z "$1"; echo "$e"; } # empty->0; non-empty->1
103 103

  
104 104

  
105 105
#### arrays

Also available in: Unified diff