summary refs log tree commit diff
path: root/Completion
diff options
context:
space:
mode:
Diffstat (limited to 'Completion')
-rw-r--r--Completion/Unix/Command/_perl14
1 files changed, 13 insertions, 1 deletions
diff --git a/Completion/Unix/Command/_perl b/Completion/Unix/Command/_perl
index b00baa6ed..19212126e 100644
--- a/Completion/Unix/Command/_perl
+++ b/Completion/Unix/Command/_perl
@@ -4,6 +4,7 @@
 # Adam Spiers <adam@spiers.net>
 #
 # Completions currently based on Perl 5.14.1.
+typeset -A opt_args
 
 _perl () {
   _arguments -s \
@@ -40,10 +41,21 @@ _perl () {
     "(-w    -X)-W[enable all warnings (ignores 'no warnings')]" \
     "(-w -W   )-X[disable all warnings (ignores 'use warnings')]" \
     '-x-[strip off text before #!perl line and perhaps cd to directory]:directory to cd to:_files -/' \
-    '1:Perl script:_files -/ -g "*.(p[ml]|PL|t)(-.)"' \
+    '1:script or arg:_script_or_arg' \
     '*::args: _normal'
 }
 
+_script_or_arg () {
+  local expl
+  if [[ -n "$opt_args[(I)-(e|E)]" ]]; then
+    _description arg expl 'file'
+    _files "$expl[@]"
+  else
+    _description script expl 'Perl script'
+    _files "$expl[@]" -/ -g "*.(p[ml]|PL|t)(-.)"
+  fi
+}
+
 _perl_m_opt () {
   compset -P '-'