Revision 9075
Added by Aaron Marcuse-Kubitza about 11 years ago
util.sh | ||
---|---|---|
4 | 4 |
if test ! "$_util_sh_include_guard_utils"; then |
5 | 5 |
_util_sh_include_guard_utils=1 |
6 | 6 |
|
7 |
function extern() { (exec "$@") || return; } |
|
8 |
|
|
9 | 7 |
isset() { test "${!1+isset}"; } |
10 | 8 |
|
11 | 9 |
realpath() { readlink -f -- "$1"; } |
12 | 10 |
|
13 |
include_guard_var() { realpath "$1"|"extern" sed 's/[^a-zA-Z0-9_]/_/g'; }
|
|
11 |
include_guard_var() { realpath "$1"|"command" sed 's/[^a-zA-Z0-9_]/_/g'; }
|
|
14 | 12 |
|
15 | 13 |
self_not_included() # usage: if self_not_included; then ... fi |
16 | 14 |
{ |
... | ... | |
153 | 151 |
|
154 | 152 |
echo_cmd() |
155 | 153 |
{ |
156 |
case "$1" in extern) shift;; esac # extern implied by the log_level
|
|
154 |
case "$1" in command) shift;; esac # command implied by the log_level
|
|
157 | 155 |
log "$*" |
158 | 156 |
} |
159 | 157 |
|
... | ... | |
177 | 175 |
for cmd in rm; do alias "$cmd=echo_run $cmd"; done; unset cmd |
178 | 176 |
|
179 | 177 |
# echo all external commands |
180 |
alias extern="echo_run extern " # last space alias-expands next word
|
|
178 |
alias command="echo_run command " # last space alias-expands next word
|
|
181 | 179 |
|
182 |
alias self='extern "$FUNCNAME"' # usage: wrapper() { self ...; }
|
|
180 |
alias self='command "$FUNCNAME"' # usage: wrapper() { self ...; }
|
|
183 | 181 |
|
184 | 182 |
# commands that are always external |
185 |
for cmd in env; do alias "$cmd=extern $cmd"; done; unset cmd
|
|
183 |
for cmd in env; do alias "$cmd=command $cmd"; done; unset cmd
|
|
186 | 184 |
|
187 | 185 |
function echo_func() |
188 | 186 |
{ |
Also available in: Unified diff
*{.sh,run}: replaced extern with command, a shell builtin that does the same thing. this is also part of dash (the Bourne shell on Linux).