aboutsummaryrefslogtreecommitdiffstats
path: root/icevault
diff options
context:
space:
mode:
authorGuilhem Moulin <guilhem@fripost.org>2015-03-20 16:13:08 +0100
committerGuilhem Moulin <guilhem@fripost.org>2015-03-20 16:13:08 +0100
commit135d72ac87f20a164c3e29de186dfa642d3b650b (patch)
tree738053299da8abd3c63af3b8e5b82e276bb4a2d3 /icevault
parent8ec9c5f75200d7a54015cc3bd86cbe7a0836cc43 (diff)
wibble
Diffstat (limited to 'icevault')
-rwxr-xr-xicevault13
1 files changed, 7 insertions, 6 deletions
diff --git a/icevault b/icevault
index eb073cb..800f8a2 100755
--- a/icevault
+++ b/icevault
@@ -24,7 +24,7 @@ use Getopt::Long qw/:config posix_default no_ignore_case gnu_compat
bundling auto_version/;
use Encode qw/decode_utf8 encode_utf8/;
use I18N::Langinfo ();
-use List::Util qw/any first min none/;
+use List::Util qw/all any first min none/;
# Clean up PATH, and set TMPDIR to a ramdisk's mountpoint if possible
@@ -285,15 +285,16 @@ sub complete($;$) {
return @matches if $all or $#matches < 1;
# find the longest common prefix to determine the depth level of completion
- my $p = $matches[0];
- do { chop $p until /\A\Q$p\E/ } foreach @matches;
+ $matches[0] =~ /\A([A-Za-z0-9-]+):\/\/([^\P{Graph}:\/]+(?::\d+)?)\// or die;
+ ($s, $h) = ($1, $2);
- if ($p =~ /\A[A-Za-z0-9-]+:\/\/[^\P{Graph}:\/]+(?::\d+)?\//) {
- } elsif ($p =~ /\A[A-Za-z0-9-]+:\/\//) {
+ if (all { /\A\Q$s\E:\/\/\Q$h\E\// } @matches) { # common host: list all ids
+ } elsif (all { /\A\Q$s\E:\/\// } @matches) { # common scheme: list only hosts
s#/[^\P{Print}\/]+\z#/# foreach @matches;
- } elsif (defined $s) {
+ } else { # no common scheme: list only schemes
s#://[^\P{Graph}\/]+/[^\P{Print}\/]+\z#://# foreach @matches;
}
+
my %matches = map {( $_ => 1 )} @matches;
return keys %matches;
}