Project

General

Profile

« Previous | Next » 

Revision 9056

lib/sh/util.sh: moved echo_cmd, echo_run before commands that use them

View differences:

lib/sh/util.sh
160 160
fi # load new aliases
161 161
if self_being_included; then
162 162

  
163
echo_cmd ()
164
{
165
	if can_log; then
166
		case "$1" in extern) shift;; esac # extern implied by the log_level
167
		echo "$PS4$*" >&2
168
	fi
169
}
170

  
171
echo_run () { cmd2rel_path; echo_cmd "$@"; "$@"; }
172

  
163 173
# usage: (limit_stderr; cmd...) || return
164 174
# `|| return` needed on Mac because of bug where -e doesn't apply to ()
165 175
limit_stderr () { inc_log_level; if ! can_log; then exec 2>/dev/null; fi; }
......
174 184
}
175 185
alias limit_stderr_cmd='limit_stderr_cmd ' # last space alias-expands next word
176 186

  
177
echo_cmd ()
178
{
179
	if can_log; then
180
		case "$1" in extern) shift;; esac # extern implied by the log_level
181
		echo "$PS4$*" >&2
182
	fi
183
}
184

  
185
echo_run () { cmd2rel_path; echo_cmd "$@"; "$@"; }
186

  
187 187
# auto-echo common external commands
188 188
for cmd in rm; do alias "$cmd=echo_run $cmd"; done; unset cmd
189 189

  

Also available in: Unified diff