Skip to content

Commit

Permalink
man, mutt: avoid errors in nounset mode on Ubuntu 14 and 16
Browse files Browse the repository at this point in the history
  • Loading branch information
scop committed May 31, 2020
1 parent 1a633f3 commit e5fa022
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
12 changes: 7 additions & 5 deletions completions/man
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,13 @@ _man()
COMPREPLY=($(eval command ls "$manpath" 2>/dev/null))
$reset

# weed out directory path names and paths to man pages
COMPREPLY=(${COMPREPLY[@]##*/?(:)})
# strip suffix from man pages
COMPREPLY=(${COMPREPLY[@]%$comprsuffix})
COMPREPLY=($(compgen -W '${COMPREPLY[@]%.*}' -- "${cur//\\\\/}"))
if ((${#COMPREPLY[@]} != 0)); then
# weed out directory path names and paths to man pages
COMPREPLY=(${COMPREPLY[@]##*/?(:)})
# strip suffix from man pages
COMPREPLY=(${COMPREPLY[@]%$comprsuffix})
COMPREPLY=($(compgen -W '${COMPREPLY[@]%.*}' -- "${cur//\\\\/}"))
fi

# shellcheck disable=SC2053
if [[ $prev != $mansect ]]; then
Expand Down
6 changes: 3 additions & 3 deletions completions/mutt
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ _muttrc()
shift
done

if [[ -z $muttrc ]]; then
if [[ ! -v muttrc ]]; then
if [[ -f ~/.${muttcmd}rc ]]; then
muttrc=\~/.${muttcmd}rc
elif [[ -f ~/.${muttcmd}/${muttcmd}rc ]]; then
muttrc=\~/.${muttcmd}/${muttcmd}rc
fi
fi
printf "%s" "$muttrc"
printf "%s" "${muttrc-}"
}

# Recursively build list of sourced config files
Expand All @@ -54,7 +54,7 @@ _muttconffiles()
shift
while [[ ${1-} ]]; do
newconffiles=($(command sed -n 's|^source[[:space:]]\{1,\}\([^[:space:]]\{1,\}\).*$|\1|p' "$(eval printf %s $1)"))
for file in "${newconffiles[@]}"; do
for file in ${newconffiles+"${newconffiles[@]}"}; do
__expand_tilde_by_ref file
[[ ! -f $file || $sofar == *\ $file\ * ]] && continue
sofar+=" $file"
Expand Down

0 comments on commit e5fa022

Please sign in to comment.