Complete-Bash
view release on metacpan or search on metacpan
- [dist] Move spec prereqs from RuntimeRequires to
DevelopRecommends to reduce deps but still allow indicating spec
requirement.
0.19 2015-04-02 Released-By: PERLANCAR
- No functional changes.
- Skip tests on platforms that do not implement getpwuid [CT].
0.18 2015-03-31 Released-By: PERLANCAR
- [Internal] Reimplement parse_cmdline() using regex instead of C-like
char-by-char parsing.
- [Removed feature] Remove option/parameter 'preserve_quotes' and
'word_breaks' because they are never used in my applications/other
libraries (and they complicate the new regex-based parsing
lib/Complete/Bash.pm view on Meta::CPAN
v => 1.1,
summary => 'Completion routines for bash shell',
};
sub _expand_tilde {
my ($user, $slash) = @_;
my @ent;
if (length $user) {
@ent = getpwnam($user);
} else {
@ent = getpwuid($>);
$user = $ent[0];
}
return $ent[7] . $slash if @ent;
"~$user$slash"; # return as-is when failed
}
sub _add_unquoted {
no warnings 'uninitialized';
my ($word, $is_cur_word, $after_ws) = @_;
t/parse_cmdline.t view on Meta::CPAN
# double quote still allows variable substitution
is_deeply(parse_cmdline(point(q|a^ "$var|)), [['a', 'foo'], 0]);
# single quote prevents variable substitution
is_deeply(parse_cmdline(point(q|a^ '$var|)), [['a', '$var'], 0]);
};
subtest "tilde expansion" => sub {
my @ent;
eval { @ent = getpwuid($>) };
$@ and plan skip_all => 'getpwuid($>) dies (probably not implemented)';
@ent or plan skip_all => 'getpwuid($>) is empty';
is_deeply(parse_cmdline(point(q|a^ ~|)), [['a', "$ent[7]"], 0]);
is_deeply(parse_cmdline(point(q|a^ ~/|)), [['a', "$ent[7]/"], 0]);
is_deeply(parse_cmdline(point(q|a^ ~/b|)), [['a', "$ent[7]/b"], 0]);
is_deeply(parse_cmdline(point(q|a^ ~/~|)), [['a', "$ent[7]/~"], 0]);
# not an expanded tilde
is_deeply(parse_cmdline(point(q|a^ a~|)), [['a', "a~"], 0]);
is_deeply(parse_cmdline(point(q|a^ ""~|)), [['a', "~"], 0]);
( run in 0.272 second using v1.01-cache-2.11-cpan-8d75d55dd25 )