Revision 9313
Added by Aaron Marcuse-Kubitza over 11 years ago
lib/sh/util.sh | ||
---|---|---|
279 | 279 |
|
280 | 280 |
#### paths |
281 | 281 |
|
282 |
# cache realpath |
|
283 |
: "${realpath_cache=}" # default off because slower than without |
|
284 |
if test "$realpath_cache"; then |
|
285 |
func_override realpath__no_cache |
|
286 |
realpath() # caches the last result for efficiency |
|
287 |
{ |
|
288 |
local cache_key="$*"; load_cache |
|
289 |
if ! cached; then save_cache "$(realpath__no_cache "$@")"; fi |
|
290 |
echo_cached_value |
|
291 |
} |
|
292 |
fi |
|
293 |
|
|
282 | 294 |
rel_path() # usage: base_dir=... path=... rel_path |
283 | 295 |
{ |
284 | 296 |
log++; kw_params base_dir path |
... | ... | |
444 | 456 |
can_log && caller_indent || true |
445 | 457 |
# -P: expand symlinks so $PWD matches the output of realpath |
446 | 458 |
builtin "$FUNCNAME" -P "$@" |
459 |
|
|
460 |
func=realpath clear_cache |
|
447 | 461 |
set_paths |
448 | 462 |
} |
449 | 463 |
|
Also available in: Unified diff
lib/sh/util.sh: added support for caching realpath() using the new shell-variable-based caching. this can be enabled via $realpath_cache and defaults to off because it's currently slower than without. note that the cache needs to be cleared in cd() because relative paths will become invalid.