Support tildes when recursively sourcing muttrc files (Debian: #615134).

This commit is contained in:
Ville Skyttä 2011-04-14 22:17:09 +03:00
parent f0a9128649
commit 1ffb918b4e
6 changed files with 15 additions and 1 deletions

View File

@ -12,6 +12,7 @@ bash-completion (2.x)
* Install full path /etc/rc.d/init.d/* completions. * Install full path /etc/rc.d/init.d/* completions.
* Try both full path and basename completions for sudo etc (Alioth: #313065). * Try both full path and basename completions for sudo etc (Alioth: #313065).
* Don't install completions for init.d backup files. * Don't install completions for init.d backup files.
* Support tildes when recursively sourcing muttrc files (Debian: #615134).
[ Guillaume Rousse ] [ Guillaume Rousse ]
* added puppet completion, using work from Mathieu Parent (sathieudebian.org) * added puppet completion, using work from Mathieu Parent (sathieudebian.org)

View File

@ -61,6 +61,7 @@ _muttconffiles()
while [[ "$1" ]]; do while [[ "$1" ]]; do
newconffiles=( $(sed -n 's|^source[[:space:]]\{1,\}\([^[:space:]]\{1,\}\).*$|\1|p' $(eval echo $1) ) ) newconffiles=( $(sed -n 's|^source[[:space:]]\{1,\}\([^[:space:]]\{1,\}\).*$|\1|p' $(eval echo $1) ) )
for file in "${newconffiles[@]}"; do for file in "${newconffiles[@]}"; do
__expand_tilde_by_ref file
[[ ! -f "$file" || "${sofar/ ${file} / }" != "$sofar" ]] && [[ ! -f "$file" || "${sofar/ ${file} / }" != "$sofar" ]] &&
continue continue
sofar+=" $file" sofar+=" $file"

1
test/fixtures/mutt/bar/muttrc_b vendored Normal file
View File

@ -0,0 +1 @@
source ~/foo/muttrc_f

0
test/fixtures/mutt/foo/muttrc_f vendored Normal file
View File

View File

@ -1,3 +1,4 @@
set folder=. set folder=.
alias a1 a1@example.com alias a1 a1@example.com
alias a2 a2@example.com alias a2 a2@example.com
source ~/bar/muttrc_b

View File

@ -1,10 +1,15 @@
proc setup {} { proc setup {} {
save_env save_env
assert_bash_exec {OLDHOME=$HOME ; HOME=$SRCDIRABS/fixtures/mutt}
} }
proc teardown {} { proc teardown {} {
assert_env_unmodified {/OLDPWD=/d} assert_bash_exec {HOME=$OLDHOME}
assert_env_unmodified {
/OLDPWD=/d
/OLDHOME=/d
}
} }
@ -30,4 +35,9 @@ assert_complete_dir $expected "mutt -F muttrc -A " $::srcdir/fixtures/mutt
sync_after_int sync_after_int
set expected "$::srcdirabs/fixtures/mutt/muttrc $::srcdirabs/fixtures/mutt/bar/muttrc_b $::srcdirabs/fixtures/mutt/foo/muttrc_f"
assert_bash_list $expected { _muttconffiles "$HOME/muttrc" "$HOME/muttrc" } "find muttrcs recursively"
sync_after_int
teardown teardown