From a0afe0959bf322e894cda25c8d409b2451a8dd7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Sun, 24 Apr 2011 20:14:48 +0300 Subject: [PATCH] Try to figure out file/dir argument types from --foo=BAR in _longopt(). --- bash_completion | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/bash_completion b/bash_completion index e550af8e..f1def504 100644 --- a/bash_completion +++ b/bash_completion @@ -1619,6 +1619,21 @@ _longopt() _filedir return 0 ;; + --+([-a-z0-9_])) + local argtype=$( $1 --help 2>&1 | \ + sed -ne "s|.*$prev\[\?=[<[]\?\([-A-Za-z0-9_]\{1,\}\).*|\1|p" ) + case ${argtype,,} in + *dir*) + compopt +o default + _filedir -d + return 0 + ;; + *file*|*path*) + _filedir + return 0 + ;; + esac + ;; esac $split && return 0