File tree 1 file changed +13
-17
lines changed
1 file changed +13
-17
lines changed Original file line number Diff line number Diff line change @@ -307,30 +307,26 @@ absolutify() {
307
307
local file_path=" $1 "
308
308
local file_path_dirname=" ${file_path%/* } "
309
309
local file_path_basename=" ${file_path##*/ } "
310
- abs_path_cached " $file_path_dirname "
311
- local file_abs_path=" $abs_path_cached_retval "
310
+ local file_abs_path
311
+ # Update cached abs path only if the argument differs from the last invocation
312
+ if [ ! " $file_path_dirname " = " ${_absolutiy_file_path_dirname-} " ]
313
+ then
314
+ _absolutiy_file_path_dirname=" $file_path_dirname "
315
+ # Unset CDPATH because it causes havok: it makes the destination unpredictable
316
+ # and triggers 'cd' to print the path to stdout. Route `cd`'s output to /dev/null
317
+ # for good measure.
318
+ _absolutiy_file_abs_path=" $( CDPATH= cd " $file_path_dirname " > /dev/null && pwd) "
319
+ fi
320
+ file_abs_path=" ${_absolutiy_file_abs_path-} "
312
321
local file_path=" $file_abs_path /$file_path_basename "
313
322
# This is the return value
314
323
RETVAL=" $file_path "
315
324
}
316
325
317
326
# Prints the absolute path of a directory to stdout
318
327
abs_path () {
319
- abs_path_cached " $@ "
320
- printf %s " $abs_path_cached_retval "
321
- }
322
-
323
- abs_path_cached () {
324
- local path=" $1 "
325
- # Update return value only if the argument differs from the last invocation
326
- if ! [ " $path " = " ${_abs_path_cached_key:- } " ]
327
- then
328
- _abs_path_cached_key=" $path "
329
- # Unset CDPATH because it causes havok: it makes the destination unpredictable
330
- # and triggers 'cd' to print the path to stdout. Route `cd`'s output to /dev/null
331
- # for good measure.
332
- abs_path_cached_retval=" $( unset CDPATH && cd " $path " > /dev/null && pwd) "
333
- fi
328
+ absolutify " $@ "
329
+ printf %s " $RETVAL "
334
330
}
335
331
336
332
uninstall_legacy () {
You can’t perform that action at this time.
0 commit comments