diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2016-11-20 23:30:27 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2016-11-20 23:30:27 +0300 |
commit | 3d0b16d4cac0f415ef47edf098e42e49db093223 (patch) | |
tree | ce18060e7604a5cab561baa1b5cfe8a3a96eba65 /%HOME% | |
parent | don't set -o nounset (diff) | |
download | linux-home-3d0b16d4cac0f415ef47edf098e42e49db093223.tar.gz linux-home-3d0b16d4cac0f415ef47edf098e42e49db093223.zip |
refactoring
Diffstat (limited to '%HOME%')
-rw-r--r-- | %HOME%/.bash_utils/distr.sh | 8 | ||||
-rw-r--r-- | %HOME%/.bash_utils/path.sh | 22 |
2 files changed, 14 insertions, 16 deletions
diff --git a/%HOME%/.bash_utils/distr.sh b/%HOME%/.bash_utils/distr.sh index e83cb88..fc77d9e 100644 --- a/%HOME%/.bash_utils/distr.sh +++ b/%HOME%/.bash_utils/distr.sh @@ -56,10 +56,8 @@ sums_update() ( existing[$path]=1 done < <( sums_list_paths -z ) - for path in "$@"; do - if [ -z "${existing[$path]+x}" ]; then - missing+=("$path") - fi + for path; do + [ -z "${existing[$path]+x}" ] && missing+=("$path") done [ "${#missing[@]}" -eq 0 ] && return 0 @@ -75,7 +73,7 @@ sums_update_distr() ( while IFS= read -d '' -r path; do paths+=("$path") - done < <( find -type f -\( -iname '*.exe' -o -iname '*.iso' -\) -printf '%P\0' ) + done < <( find . -type f -\( -iname '*.exe' -o -iname '*.iso' -\) -printf '%P\0' ) sums_update ${paths[@]+"${paths[@]}"} ) diff --git a/%HOME%/.bash_utils/path.sh b/%HOME%/.bash_utils/path.sh index 13b5b00..57f1ab5 100644 --- a/%HOME%/.bash_utils/path.sh +++ b/%HOME%/.bash_utils/path.sh @@ -12,11 +12,11 @@ add_missing_path() ( [ "$#" -eq 0 ] && return 0 - local -a new_list + local -a src_list local path while IFS= read -d '' -r path; do - new_list+=("$path") + src_list+=("$path") done < <( readlink -z --canonicalize-missing -- "$@" ) for path; do @@ -26,23 +26,23 @@ add_missing_path() ( fi done - local -A old_dict - local -a old_list + local -A dest_dict + local -a dest_list if [ -n "${PATH-}" ]; then while IFS= read -d '' -r path; do - old_dict[$path]=1 - old_list+=("$path") + dest_dict[$path]=1 + dest_list+=("$path") done < <( str_split -z -- "${PATH-}" ':' | xargs -0 -- readlink -z --canonicalize-missing -- ) fi - for path in ${new_list[@]+"${new_list[@]}"}; do - [ -n "${old_dict[$path]+x}" ] && continue - old_dict[$path]=1 - old_list+=("$path") + for path in ${src_list[@]+"${src_list[@]}"}; do + [ -n "${dest_dict[$path]+x}" ] && continue + dest_dict[$path]=1 + dest_list+=("$path") done - str_join ':' ${old_list[@]+"${old_list[@]}"} + str_join ':' ${dest_list[@]+"${dest_list[@]}"} ) add_path() { |