Fix static analysis and lint errors
This commit is contained in:
parent
8494eda973
commit
d7e8831423
9 changed files with 116 additions and 117 deletions
|
|
@ -5,20 +5,18 @@
|
|||
|
||||
# In case a plugin adds a redundant path entry, remove duplicate entries
|
||||
# from PATH
|
||||
#
|
||||
# This snippet is from Mislav Marohnić <mislav.marohnic@gmail.com>'s
|
||||
# dotfiles repo at https://github.com/mislav/dotfiles
|
||||
dedupe_path() {
|
||||
typeset -a paths result
|
||||
paths=($path)
|
||||
|
||||
while [[ ${#paths} -gt 0 ]]; do
|
||||
p="${paths[1]}"
|
||||
shift paths
|
||||
[[ -z ${paths[(r)$p]} ]] && result+="$p"
|
||||
done
|
||||
|
||||
export PATH=${(j+:+)result}
|
||||
# from: https://unix.stackexchange.com/questions/40749/remove-duplicate-path-entries-with-awk-command
|
||||
get_var() {
|
||||
eval 'printf "%s\n" "${'"$1"'}"'
|
||||
}
|
||||
|
||||
dedupe_path
|
||||
set_var() {
|
||||
eval "$1=\"\$2\""
|
||||
}
|
||||
dedup_pathvar() {
|
||||
pathvar_name="$1"
|
||||
pathvar_value="$(get_var "$pathvar_name")"
|
||||
deduped_path="$(perl -e 'print join(":",grep { not $seen{$_}++ } split(/:/, $ARGV[0]))' "$pathvar_value")"
|
||||
set_var "$pathvar_name" "$deduped_path"
|
||||
}
|
||||
dedup_pathvar PATH
|
||||
dedup_pathvar MANPATH
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue