summaryrefslogtreecommitdiff
path: root/debian
diff options
context:
space:
mode:
authorGabriel F. T. Gomes <gabriel@inconstante.eti.br>2018-12-02 10:52:31 -0200
committerGabriel F. T. Gomes <gabriel@inconstante.eti.br>2018-12-02 11:24:29 -0200
commitd4e44fb5737f367c220b90a664794dc7552ebfa5 (patch)
tree675febf2ff7feb6909dcc2a702eabecfe3ca52e9 /debian
parent87297041a8eb83a4b6fadfd64d111ee5fb6746e5 (diff)
downloadbash-completion-d4e44fb5737f367c220b90a664794dc7552ebfa5.tar.gz
Update for perl completion fix (bug #614775)
Debian commit: commit 5506a39b0f16cee692f44c209a0d1a3b98fa969f Author: Gabriel F. T. Gomes <gabriel@inconstante.eti.br> Date: Sat Nov 24 15:25:42 2018 -0200 Fix perl completion with space between option and argument (bug #614775) incorporated a fix for perl completions, however the fix was not fully correct. This commit updates the patch. Also fix an error with debian/changelog syntax for the relevant entry.
Diffstat (limited to 'debian')
-rw-r--r--debian/changelog2
-rw-r--r--debian/patches/13-fix-perl-completions-with-a-space-between-option-and.patch153
2 files changed, 62 insertions, 93 deletions
diff --git a/debian/changelog b/debian/changelog
index 286bed8f..2359370a 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,7 +1,7 @@
bash-completion (1:2.8-5) UNRELEASED; urgency=medium
* Fix perl completions with a space between option and argument.
- (Closes #614775)
+ (Closes: #614775)
* Fix COMP_FILEDIR_FALLBACK to address comment #45 on bug #550676
(https://bugs.debian.org/550676#45). (Closes: #550676)
diff --git a/debian/patches/13-fix-perl-completions-with-a-space-between-option-and.patch b/debian/patches/13-fix-perl-completions-with-a-space-between-option-and.patch
index fd48bea6..b7779f39 100644
--- a/debian/patches/13-fix-perl-completions-with-a-space-between-option-and.patch
+++ b/debian/patches/13-fix-perl-completions-with-a-space-between-option-and.patch
@@ -4,108 +4,69 @@ Origin: vendor, https://bugs.debian.org/614775
Bug-Debian: https://bugs.debian.org/614775
Forwarded: yes, https://github.com/scop/bash-completion/pull/258
-When trying to complete the name of a script after "-d", I get no
-completions. E.g.:
-
- perl -d <tab>
-
-The problem is that there are two cases:
-
- 1. We are at "-d*", so we shift that into $prev, put the rest of it in
- $cur, and then look for ":*" in $cur.
-
- 2. We are at "-d ", and $prev remains "-d", but we still try to look
- for ":*" in $cur.
-
-So case (2) is wrong; we will complete "-d :DProf", which doesn't make
-any sense (and isn't accepted by perl). And if you have no colon, you
-get no completions at all.
-
-There is a similar problem for "-V:" and "-M" (which will complete "-M
-module", which perl complains about).
-
-The description above was copied from a Debian bug report [1].
-The following lines were added by Gabriel F. T. Gomes.
-
-After the change, the following completion attempts produce:
-
- $ ls[ENTER]
- dir1 dir2 file1 file2
-
- $ perl -d :[TAB]
- (no output)
- $ perl -d:[TAB]
- CallChecker InnerPackage PPPort StackTrace::Frame
- Caller LexAlias SelfStubber
- GlobalDestruction Peek StackTrace
-
- $ perl -d [TAB]
- dir1/ dir2/ file1 file2
- $ perl -d[TAB]
- (no output)
-
-Likewise for '-V':
-
- $ perl -V :[TAB]
- (no output)
- $ perl -V:[TAB]
- Display all 1255 possibilities? (y or n) y[ENTER]
- _a d_sysernlst
- afs d_syserrlst
- afsroot d_system
- (etc.)
-
- $ perl -V [TAB]
- dir1/ dir2/ file1 file2
- $ perl -V[TAB]
- (no output)
-
-Likewise for '-M' and '-m' (identical output for both):
-
- $ perl -M [TAB]
- dir1/ dir2/ file1 file2
- $ perl -M[TAB]
- Display all 2389 possibilities? (y or n)
- -m-Algorithm::C3
- -m-Algorithm::Diff
- -m-Algorithm::DiffOld
- (etc.)
- $ perl -M-[TAB]
- Display all 2389 possibilities? (y or n)
- -m-Algorithm::C3
- -m-Algorithm::Diff
- -m-Algorithm::DiffOld
- (etc.)
-
-The options '-I' and '-x' were not mentioned in the bug report [1] for
-Debian, but they are relevant since the patch affects them (identical
-output for both):
-
- $ perl -I [TAB]
- dir1/ dir2/ file1 file2
-
- $ perl -I[TAB]
- -Idir1/ -Idir2/
- $ perl -Idir[CURSOR]
-
-These are the correct outputs based on `perl --help', which explains
-that there are no spaces between these options and their arguments. For
-instance:
-
- $ perl --help | grep "\-d\|\-V\|-I"
+Most perl options do not allow a space between the switch and the
+argument, however, bash-completion incorrectly suggests completions for
+`-d', `-M` (or `-m'), and `-V', as reported in Debian bug #614775 [1],
+as well as for `-I', and `-x', which were not mentioned in the bug
+report. This patch fixes the incorrect completions for these options,
+by falling back to regular _filedir completion when a space is present.
+
+On the other hand, and unlike all other perl options, a space between
+the `-e' and `-E' options and their arguments, e.g. `perl -e "exit 2"',
+*is* valid syntax. However, the argument is neither a filename nor a
+directory, but one line of perl program. So, in order to keep the old
+behavior, which was correct, this patch adds extra code that skips
+_filedir completion for `-e' and `-E' with a space.
+
+Finally, the test case for `-x' requires changes, because it expects
+that `-x' with a space should complete only with directories. That is
+misleading, because it might suggest that the directory would be treated
+as the argument to the `-x' option, when it will not, as can be verified
+with the following test:
+
+ $ cat test.pl
+ Some regular text with an embedded script
+ #!perl
+ use Cwd;
+ my $dir = getcwd;
+ print "$dir\n";
+ __END__
+ More text messages, not code.
+
+By executing the script with the `-x[dir]' option, the non-code part of
+the file will be ignored, i.e. only the embedded script will be
+executed. It will also be executed under [dir], if it is provided:
+
+ $ perl -xperl/ test.pl
+ /tmp/perl
+
+However, if a space is present between `-x' and [dir], the script fails,
+because the perl interpreter thinks that [dir] is a script, not the
+argument to `-x':
+
+ $ perl -x perl/ test.pl
+ Can't open perl script "perl/": Is a directory
+
+The rationale for the changes is based on `perl --help', which explains
+that there are no spaces between options and arguments:
+
+ $ perl --help | grep "\-d\|\-V\|-I\|-x\|-\[mM\]"
-d[:debugger] run program under debugger
-Idirectory specify @INC/#include directory (several -I's allowed)
+ -[mM][-]module execute "use/no module..." before executing program
-V[:variable] print configuration summary (or a single Config.pm variable)
+ -x[directory] ignore text before #!perl line (optionally cd to directory)
When a space is required, `perl --help' makes it explicit:
- $ perl --help | grep "\-E"
+ $ perl --help | grep "\-e\|-E"
+ -e program one line of program (several -e's allowed, omit programfile)
-E program like -e, but enables all optional features
[1] https://bugs.debian.org/614775
---
diff --git a/completions/perl b/completions/perl
-index 250039e..4f6e18c 100644
+index 7b91d1b4..98a0b53b 100644
--- a/completions/perl
+++ b/completions/perl
@@ -27,7 +27,6 @@ _perl()
@@ -116,11 +77,19 @@ index 250039e..4f6e18c 100644
case $prev in
-D|-e|-E|-i|-F|-l)
-@@ -68,7 +67,7 @@ _perl()
+@@ -68,7 +67,15 @@ _perl()
;;
esac
- if [[ "$cur" == -* ]]; then
++ # Unlike other perl options, having a space between the `-e' and
++ # `-E' options and their arguments, e.g. `perl -e "exit 2"', is
++ # valid syntax. However, the argument is neither a filename nor a
++ # directory, but one line of perl program, thus do not suggest
++ # _filedir completion.
++ elif [[ "$prev" == -e ]] || [[ "$prev" == -E ]]; then
++ return
++
+ elif [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-C -s -T -u -U -W -X -h -v -V -c -w -d -D -p
-n -a -F -l -0 -I -m -M -P -S -x -i -e' -- "$cur" ) )