|
|
@ -226,7 +226,7 @@ function truncatePath() {
|
|
|
|
# convert $2 from string to integer
|
|
|
|
# convert $2 from string to integer
|
|
|
|
2=$(( $2 ))
|
|
|
|
2=$(( $2 ))
|
|
|
|
# set $3 to "" if not defined
|
|
|
|
# set $3 to "" if not defined
|
|
|
|
[[ -z $3 ]] && local 3="" || 3=$(echo -n $3)
|
|
|
|
[[ -z $3 ]] && 3="" || 3=$(echo -n $3)
|
|
|
|
# set $4 to "right" if not defined
|
|
|
|
# set $4 to "right" if not defined
|
|
|
|
[[ -z $4 ]] && 4="right"
|
|
|
|
[[ -z $4 ]] && 4="right"
|
|
|
|
# create a variable for the truncated path.
|
|
|
|
# create a variable for the truncated path.
|
|
|
@ -237,14 +237,12 @@ function truncatePath() {
|
|
|
|
local paths=$1
|
|
|
|
local paths=$1
|
|
|
|
paths=(${(s:/:)${paths//"~\/"/}})
|
|
|
|
paths=(${(s:/:)${paths//"~\/"/}})
|
|
|
|
# declare locals for the directory being tested and its length
|
|
|
|
# declare locals for the directory being tested and its length
|
|
|
|
local test_dir test_dir_length delim_len
|
|
|
|
local test_dir test_dir_length
|
|
|
|
# do the needed truncation
|
|
|
|
# do the needed truncation
|
|
|
|
case $4 in
|
|
|
|
case $4 in
|
|
|
|
right)
|
|
|
|
right)
|
|
|
|
# check the length of the delimiter
|
|
|
|
|
|
|
|
[[ -z $3 ]] && delim_len=${#3} || delim_len=0
|
|
|
|
|
|
|
|
# include the delimiter length in the threshhold
|
|
|
|
# include the delimiter length in the threshhold
|
|
|
|
local threshhold=$(( $2 + $delim_len ))
|
|
|
|
local threshhold=$(( $2 + ${#3} ))
|
|
|
|
# loop through the paths
|
|
|
|
# loop through the paths
|
|
|
|
for (( i=1; i<${#paths}; i++ )); do
|
|
|
|
for (( i=1; i<${#paths}; i++ )); do
|
|
|
|
# get the current directory value
|
|
|
|
# get the current directory value
|
|
|
|