From 2da0c12fd1018318db42af050b1d1698e9771a0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20Mengu=C3=A9?= Date: Wed, 9 Jul 2014 22:55:48 +0200 Subject: [PATCH] _lp_shorten_path: clean variable usage inside (( )) --- liquidprompt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/liquidprompt b/liquidprompt index 4ad000f..5f16b51 100755 --- a/liquidprompt +++ b/liquidprompt @@ -579,13 +579,13 @@ _lp_shorten_path() local p="$(_lp_get_home_tilde_collapsed)" local mask="${LP_MARK_SHORTEN_PATH}" - local -i max_len=$(( ${COLUMNS:-80} * $LP_PATH_LENGTH / 100 )) + local -i max_len=$(( ${COLUMNS:-80} * LP_PATH_LENGTH / 100 )) if [[ ${LP_PATH_KEEP} == -1 ]]; then # only show the current directory, excluding any parent dirs ret="${p##*/}" # discard everything up to and including the last slash [[ "${ret}" == "" ]] && ret="/" # if in root directory - elif (( ${#p} <= ${max_len} )); then + elif (( ${#p} <= max_len )); then ret="${p}" elif [[ ${LP_PATH_KEEP} == 0 ]]; then # len is over max len, show as much of the tail as is allowed @@ -598,8 +598,8 @@ _lp_shorten_path() local tmp=${p//\//} local -i delims=$(( ${#p} - ${#tmp} )) - for (( dir=0; dir < ${LP_PATH_KEEP}; dir++ )); do - (( ${dir} == ${delims} )) && break + for (( dir=0; dir < LP_PATH_KEEP; dir++ )); do + (( dir == delims )) && break local left="${p#*/}" local name="${p:0:${#p} - ${#left}}" @@ -607,7 +607,7 @@ _lp_shorten_path() ret="${ret}${name%/}/" done - if (( ${delims} <= ${LP_PATH_KEEP} )); then + if (( delims <= LP_PATH_KEEP )); then # no dirs between LP_PATH_KEEP leading dirs and current dir ret="${ret}${p##*/}" else @@ -617,7 +617,7 @@ _lp_shorten_path() [[ ${ret} != "/" ]] && ret="${ret%/}" # strip trailing slash - local -i len_left=$(( ${max_len} - ${#ret} - ${#base} - ${#mask} )) + local -i len_left=$(( max_len - ${#ret} - ${#base} - ${#mask} )) ret="${ret}${mask}${p:${#p} - ${len_left}}${base}" fi