[Bash-completion-commits] [SCM] bash-completion branch, master, updated. 1.3-104-gaa411dd

Ville Skyttä ville.skytta at iki.fi
Thu Apr 21 09:41:54 UTC 2011


The following commit has been merged in the master branch:
commit 6589a0d61bee64b9755104cf9bd9670015c2f657
Author: Ville Skyttä <ville.skytta at iki.fi>
Date:   Thu Apr 21 12:20:59 2011 +0300

    Drop support for bash < 4.1, clean up no longer needed low hanging cruft.

diff --git a/README b/README
index 71758cd..4931712 100644
--- a/README
+++ b/README
@@ -12,7 +12,7 @@ if [ -f /etc/bash_completion ]; then
   . /etc/bash_completion
 fi
 
-(if you happen to have *only* bash >= 3.2 installed, see further if not)
+(if you happen to have *only* bash >= 4.1 installed, see further if not)
 
 If you don't have the package readily available for your distribution, or
 you simply don't want to use one, you can install bash completion using the
@@ -291,12 +291,10 @@ guidelines in mind:
   start interpreters. Use lightweight programs such as grep(1), awk(1)
   and sed(1).
 
-- Use the full power of bash >= 3.2. We no longer support earlier bash
+- Use the full power of bash >= 4.1. We no longer support earlier bash
   versions, so you may as well use all the features of that version of
   bash to optimise your code. However, be careful when using features
-  added since bash 3.2, since not everyone will be able to use them. Be
-  ESPECIALLY careful of using features exclusive to 4.x, as many people
-  are still using 3.x.
+  added since bash 4.1, since not everyone will be able to use them.
 
   For example, extended globs often enable you to avoid the use of
   external programs, which are expensive to fork and execute, so do
diff --git a/TODO b/TODO
index 7a5afe5..367fd5e 100644
--- a/TODO
+++ b/TODO
@@ -2,7 +2,7 @@ bash completion needs to be rewritten from the ground up.
 ---------------------------------------------------------
 
 bash completion really needs to be rewritten from the ground up, using all of
-the features available in bash 3.2+ and without regard for compatibility with
+the features available in bash 4.1+ and without regard for compatibility with
 earlier versions.
 
 At that time, it should be split into multiple files for easier source
diff --git a/bash_completion b/bash_completion
index 3f4a9a8..fa408d0 100644
--- a/bash_completion
+++ b/bash_completion
@@ -1,5 +1,5 @@
 #
-#   bash_completion - programmable completion functions for bash 3.2+
+#   bash_completion - programmable completion functions for bash 4.1+
 #
 #   Copyright © 2006-2008, Ian Macdonald <ian at caliban.org>
 #             © 2009-2011, Bash Completion Maintainers
@@ -337,8 +337,7 @@ __reassemble_comp_words_by_ref() {
 # @param $1 exclude  Characters out of $COMP_WORDBREAKS which should NOT be
 #     considered word breaks. This is useful for things like scp where
 #     we want to return host:path and not only path, so we would pass the
-#     colon (:) as $1 in this case.  Bash-3 doesn't do word splitting, so this
-#     ensures we get the same word on both bash-3 and bash-4.
+#     colon (:) as $1 in this case.
 # @param $2 words  Name of variable to return words to
 # @param $3 cword  Name of variable to return cword to
 # @param $4 cur  Name of variable to return current word to complete to
@@ -408,9 +407,7 @@ __get_cword_at_cursor_by_ref() {
 #     -n EXCLUDE  Characters out of $COMP_WORDBREAKS which should NOT be 
 #                 considered word breaks. This is useful for things like scp
 #                 where we want to return host:path and not only path, so we
-#                 would pass the colon (:) as -n option in this case.  Bash-3
-#                 doesn't do word splitting, so this ensures we get the same
-#                 word on both bash-3 and bash-4.
+#                 would pass the colon (:) as -n option in this case.
 #     -c VARNAME  Return cur via $VARNAME
 #     -p VARNAME  Return prev via $VARNAME
 #     -w VARNAME  Return words via $VARNAME
@@ -468,8 +465,7 @@ _get_comp_words_by_ref()
 # @param $1 string  Characters out of $COMP_WORDBREAKS which should NOT be
 #     considered word breaks. This is useful for things like scp where
 #     we want to return host:path and not only path, so we would pass the
-#     colon (:) as $1 in this case.  Bash-3 doesn't do word splitting, so this
-#     ensures we get the same word on both bash-3 and bash-4.
+#     colon (:) as $1 in this case.
 # @param $2 integer  Index number of word to return, negatively offset to the
 #     current word (default is 0, previous is 1), respecting the exclusions
 #     given at $1.  For example, `_get_cword "=:" 1' returns the word left of
@@ -542,7 +538,7 @@ _get_pword()
 
 # If the word-to-complete contains a colon (:), left-trim COMPREPLY items with
 # word-to-complete.
-# On bash-3, and bash-4 with a colon in COMP_WORDBREAKS, words containing
+# With a colon in COMP_WORDBREAKS, words containing
 # colons are always completed as entire words if the word to complete contains
 # a colon.  This function fixes this, by removing the colon-containing-prefix
 # from COMPREPLY items.
@@ -558,15 +554,7 @@ _get_pword()
 # @modifies global array $COMPREPLY
 #
 __ltrim_colon_completions() {
-    # If word-to-complete contains a colon,
-    # and bash-version < 4,
-    # or bash-version >= 4 and COMP_WORDBREAKS contains a colon
-    if [[
-        "$1" == *:* && (
-            ${BASH_VERSINFO[0]} -lt 4 || 
-            (${BASH_VERSINFO[0]} -ge 4 && "$COMP_WORDBREAKS" == *:*) 
-        )
-    ]]; then
+    if [[ "$1" == *:* && "$COMP_WORDBREAKS" == *:* ]]; then
         # Remove colon-word prefix from COMPREPLY items
         local colon_word=${1%${1##*:}}
         local i=${#COMPREPLY[*]}
@@ -584,20 +572,8 @@ __ltrim_colon_completions() {
 #     $ ls "a'b/"
 #     c
 #     $ compgen -f "a'b/"       # Wrong, doesn't return output
-#     $ compgen -f "a\'b/"      # Good (bash-4)
+#     $ compgen -f "a\'b/"      # Good
 #     a\'b/c
-#     $ compgen -f "a\\\\\'b/"  # Good (bash-3)
-#     a\'b/c
-#
-# On bash-3, special characters need to be escaped extra.  This is
-# unless the first character is a single quote (').  If the single
-# quote appears further down the string, bash default completion also
-# fails, e.g.:
-#
-#     $ ls 'a&b/'
-#     f
-#     $ foo 'a&b/<TAB>  # Becomes: foo 'a&b/f'
-#     $ foo a'&b/<TAB>  # Nothing happens
 #
 # See also:
 # - http://lists.gnu.org/archive/html/bug-bash/2009-03/msg00155.html
@@ -608,17 +584,8 @@ __ltrim_colon_completions() {
 _quote_readline_by_ref()
 {
     if [[ ${1:0:1} == "'" ]]; then
-        if [[ ${BASH_VERSINFO[0]} -ge 4 ]]; then
-            # Leave out first character
-            printf -v $2 %s "${1:1}"
-        else
-            # Quote word, leaving out first character
-            printf -v $2 %q "${1:1}"
-            # Double-quote word (bash-3)
-            printf -v $2 %q ${!2}
-        fi
-    elif [[ ${BASH_VERSINFO[0]} -le 3 && ${1:0:1} == '"' ]]; then
-        printf -v $2 %q "${1:1}"
+        # Leave out first character
+        printf -v $2 %s "${1:1}"
     else
         printf -v $2 %q "$1"
     fi
@@ -674,9 +641,7 @@ _filedir()
 
     if [[ "$1" != -d ]]; then
         # Munge xspec to contain uppercase version too
-        [[ ${BASH_VERSINFO[0]} -ge 4 ]] && \
-            xspec=${1:+"!*.@($1|${1^^})"} || \
-            xspec=${1:+"!*.@($1|$(printf %s $1 | tr '[:lower:]' '[:upper:]'))"}
+        xspec=${1:+"!*.@($1|${1^^})"}
         toks+=( $( compgen -f -X "$xspec" -- $quoted ) )
     fi
 
@@ -1718,9 +1683,7 @@ _filedir_xspec()
         xspec=${xspec#!}
         matchop=@
     fi
-    [[ ${BASH_VERSINFO[0]} -ge 4 ]] && \
-        xspec="$matchop($xspec|${xspec^^})" || \
-        xspec="$matchop($xspec|$(printf %s $xspec | tr '[:lower:]' '[:upper:]'))"
+    xspec="$matchop($xspec|${xspec^^})"
 
     toks+=( $(
         eval compgen -f -X "!$xspec" -- "\$(quote_readline "\$cur")" | {
diff --git a/bash_completion.sh.in b/bash_completion.sh.in
index f6a983f..8d781a1 100644
--- a/bash_completion.sh.in
+++ b/bash_completion.sh.in
@@ -3,7 +3,7 @@
 
 # Check for recent enough version of bash.
 bash=${BASH_VERSION%.*}; bmajor=${bash%.*}; bminor=${bash#*.}
-if [ $bmajor -gt 3 ] || [ $bmajor -eq 3 -a $bminor -ge 2 ]; then
+if [ $bmajor -gt 4 ] || [ $bmajor -eq 4 -a $bminor -ge 1 ]; then
     if shopt -q progcomp && [ -r @sysconfdir@/bash_completion ]; then
         # Source completion code.
         . @sysconfdir@/bash_completion
diff --git a/completions/abook b/completions/abook
index a7ba6f1..5f46294 100644
--- a/completions/abook
+++ b/completions/abook
@@ -7,9 +7,8 @@ _abook()
     local cur prev words cword
     _init_completion || return
 
-    # abook only takes options, tabbing after command name adds a single
-    # dash (bash4)
-    [[ ${BASH_VERSINFO[0]} -ge 4 && $cword -eq 1 && -z "$cur" ]] &&
+    # abook only takes options, tabbing after command name adds a single dash
+    [[ $cword -eq 1 && -z "$cur" ]] &&
     {
         compopt -o nospace
         COMPREPLY=( "-" )
diff --git a/completions/vncviewer b/completions/vncviewer
index dcfcab8..955dd47 100644
--- a/completions/vncviewer
+++ b/completions/vncviewer
@@ -94,23 +94,13 @@ _xvnc4viewer()
             ZlibLevel \
         )
         [[ "$cur" == --* ]] && dash=-- || dash=-
-        # Is a `nocasematch' variable available (bash > v3.1)?
-        if shopt nocasematch 2> /dev/null | command grep -q ^nocasematch; then
-            # Variable `nocasematch' is available
-            # Use vncviewer camelcase options
-            local option oldNoCaseMatch=$(shopt -p nocasematch)
-            shopt -s nocasematch
-            COMPREPLY=( $( for option in "${options[@]}"; do
+
+        local option oldNoCaseMatch=$(shopt -p nocasematch)
+        shopt -s nocasematch
+        COMPREPLY=( $( for option in "${options[@]}"; do
                 [[ $dash$option == "$cur"* ]] && printf '%s\n' $dash$option
             done ) )
-            eval "$oldNoCaseMatch" 2> /dev/null
-        else
-            # Variable 'nocasematch' isn't available;
-            # Convert completions to lowercase
-            COMPREPLY=( $( compgen -W \
-                "$( tr [:upper:] [:lower:] <<<${options[@]/#/$dash} )" \
-                -- "$( tr [:upper:] [:lower:] <<<"$cur" )" ) )
-        fi
+        eval "$oldNoCaseMatch" 2>/dev/null
     else
         _known_hosts_real "$cur"
     fi
diff --git a/completions/wtf b/completions/wtf
index e34c769..545a2e5 100644
--- a/completions/wtf
+++ b/completions/wtf
@@ -22,9 +22,7 @@ _wtf()
     done
     [ -z $db ] && db=${ACRONYMDB:-/usr/share/misc/acronyms*}
 
-    [ ${BASH_VERSINFO[0]} -ge 4 ] && cur="${cur^^}"
-
-    COMPREPLY=( $( compgen -W "$( cut -f 1 -s $db ) -f" -- "${cur}" ) )
+    COMPREPLY=( $( compgen -W "$( cut -f 1 -s $db ) -f" -- "${cur^^}" ) )
 } &&
 complete -F _wtf wtf
 
diff --git a/doc/testing.txt b/doc/testing.txt
index 505d084..62b007b 100644
--- a/doc/testing.txt
+++ b/doc/testing.txt
@@ -184,11 +184,6 @@ LOG=/tmp/bash-completion.log~
     # Retrieve latest sources
 git pull
 
-    # Run tests on bash-3
-
-./runUnit       > $LOG || cat $LOG
-./runCompletion > $LOG || cat $LOG
-
     # Run tests on bash-4
 
 ./runUnit --outdir log/bash-4 --tool_exec /opt/bash-4.0/bin/bash > $LOG || cat $LOG
diff --git a/test/lib/completions/scp.exp b/test/lib/completions/scp.exp
index e6cbf8e..c436184 100644
--- a/test/lib/completions/scp.exp
+++ b/test/lib/completions/scp.exp
@@ -104,11 +104,8 @@ if {[match_items [lsort -unique $expected] -bash-sort]} {
     expect {
         -re /@ { pass "$test" }
         -re eof { unresolved "eof" }
+        default { fail "$test" }
     }
-} else {
-    # Expected failure (known bug) because of bash-4 bug in quoted words:
-    # http://www.mail-archive.com/bug-bash@gnu.org/msg06095.html
-    if {[lindex $::BASH_VERSINFO 0] >= 4} {xfail "$test"} {fail "$test"}
 }
 sync_after_int
 assert_bash_exec {cd "$TESTDIR"}
diff --git a/test/lib/library.exp b/test/lib/library.exp
index c58b9e9..a87fe89 100644
--- a/test/lib/library.exp
+++ b/test/lib/library.exp
@@ -435,13 +435,9 @@ proc _ltrim_colon_completions {cmd items dword} {
         set cur [lindex $words $index]
     }
     # If word-to-complete contains a colon,
-    # and bash-version < 4,
-    # or bash-version >= 4 and COMP_WORDBREAKS contains a colon
+    # and COMP_WORDBREAKS contains a colon
     if {
-        [string first : $cur] > -1 && (
-            [lindex $::BASH_VERSINFO 0] < 4 ||
-            ([lindex $::BASH_VERSINFO 0] >= 4 && [string first ":" $::COMP_WORDBREAKS] > -1)
-        )
+        [string first : $cur] > -1 && [string first ":" $::COMP_WORDBREAKS] > -1
     } {
         set dword_out $cur
         for {set i 0} {$i < [llength $items_out]} {incr i} {
@@ -987,29 +983,17 @@ proc start_bash {} {
     set env(SRCDIRABS) $::srcdirabs
     exp_spawn $TOOL_EXECUTABLE --rcfile $::srcdir/config/bashrc
     assert_bash_exec {} "$TOOL_EXECUTABLE --rcfile $::srcdir/config/bashrc"
-    # Bash < 3.2.41 has a bug where 'history' disappears from SHELLOPTS
-    # whenever a shopt setting is sourced or eval'ed.  Disabling 'history'
-    # makes it not show in tests "Environment should not be modified"
-    # for bash < 3.2.41.
-    # -- FVu, Tue Sep 15 22:52:00 CEST 2009
-    assert_bash_exec {is_bash_version_minimal 3 2 41 || set +o history}
 }
 
 
 # Redirect xtrace output to a file.
 #
 # 'set -x' can be very useful for debugging but by default it writes to
-# stderr. Bash 4.1 has a feature to redirect this output to a random FD.
+# stderr.
 #
 # This function uses file descriptor 6. This will break if any completion
 # tries to use the same descriptor.
 proc init_bash_xtrace {{fname xtrace.log}} {
-    global BASH_VERSINFO
-    if {([lindex $BASH_VERSINFO 0] == 4 && [lindex $BASH_VERSINFO 1] < 1) ||
-        [lindex $BASH_VERSINFO 0] < 4} {
-        note "BASH_XTRACEFD not available in this version; no xtrace.log"
-        return
-    }
     verbose "Enabling bash xtrace output to '$fname'"
     assert_bash_exec "exec 6>'$fname'"
     assert_bash_exec "BASH_XTRACEFD=6"
diff --git a/test/lib/library.sh b/test/lib/library.sh
index 98107dc..90ecdf9 100644
--- a/test/lib/library.sh
+++ b/test/lib/library.sh
@@ -4,9 +4,7 @@
 # @param $1  Char to add to $COMP_WORDBREAKS
 # @see remove_comp_wordbreak_char()
 add_comp_wordbreak_char() {
-    if [ ${BASH_VERSINFO[0]} -ge 4 ]; then
-        [[ "${COMP_WORDBREAKS//[^$1]}" ]] || COMP_WORDBREAKS=$COMP_WORDBREAKS$1
-    fi
+    [[ "${COMP_WORDBREAKS//[^$1]}" ]] || COMP_WORDBREAKS+=$1
 } # add_comp_wordbreak_char()
 
 
@@ -60,9 +58,7 @@ is_bash_version_minimal() {
 # @param $1  Char to remove from $COMP_WORDBREAKS
 # @see add_comp_wordbreak_char()
 remove_comp_wordbreak_char() {
-    if [ ${BASH_VERSINFO[0]} -ge 4 ]; then
-        COMP_WORDBREAKS=${COMP_WORDBREAKS//$1}
-    fi
+    COMP_WORDBREAKS=${COMP_WORDBREAKS//$1}
 } # remove_comp_wordbreak_char()
 
 
diff --git a/test/unit/_filedir.exp b/test/unit/_filedir.exp
index de49408..0bba831 100644
--- a/test/unit/_filedir.exp
+++ b/test/unit/_filedir.exp
@@ -124,120 +124,108 @@ foreach name {f f2} {
     sync_after_int
 
 
-    # NOTE: Bash versions 4.0.0 up to 4.0.34 contain a bug when completing quoted
-    #       words, so tests below aren't executed for these bash versions.
-    if {! (
-        [lindex $::BASH_VERSINFO 0] == 4 && 
-        [lindex $::BASH_VERSINFO 1] == 0 &&
-        [lindex $::BASH_VERSINFO 2] < 35
-    )} {
-        set cmd "$name 'ab/"
-        assert_complete_dir {e'} $cmd "$::srcdir/fixtures/_filedir"
+    set cmd "$name 'ab/"
+    assert_complete_dir {e'} $cmd "$::srcdir/fixtures/_filedir"
 
 
-        sync_after_int
+    sync_after_int
 
 
-        set cmd "$name 'a b/"
-        assert_complete_dir {i'} $cmd "$::srcdir/fixtures/_filedir"
+    set cmd "$name 'a b/"
+    assert_complete_dir {i'} $cmd "$::srcdir/fixtures/_filedir"
 
 
-        sync_after_int
+    sync_after_int
 
 
-        set cmd "$name 'a\"b/"; #"
-        assert_complete_dir {d'} $cmd "$::srcdir/fixtures/_filedir"
+    set cmd "$name 'a\"b/"; #"
+    assert_complete_dir {d'} $cmd "$::srcdir/fixtures/_filedir"
 
 
-        sync_after_int
+    sync_after_int
 
 
-        set cmd "$name 'a\$b/"
-        if {[lindex $::BASH_VERSINFO 0] == 4} {
-            assert_complete_dir {h'} $cmd "$::srcdir/fixtures/_filedir"
-        } else {
-            assert_complete_dir "\b\b\b\b$::srcdirabs/fixtures/_filedir/a\$b/h'" $cmd "$::srcdir/fixtures/_filedir"
-        }
+    set cmd "$name 'a\$b/"
+    assert_complete_dir {h'} $cmd "$::srcdir/fixtures/_filedir"
 
 
-        sync_after_int
+    sync_after_int
 
 
-        # Execute these tests only when not running on Cygwin/Windows, because
-        # directories containing `*' or `\' aren't allowed on Cygwin/Windows
-        if {! [is_cygwin]} {
-            set cmd "$name '$TESTDIR/tmp/a\\b/"
-            assert_complete_dir {g'} $cmd "$TESTDIR/tmp"
+    # Execute these tests only when not running on Cygwin/Windows, because
+    # directories containing `*' or `\' aren't allowed on Cygwin/Windows
+    if {! [is_cygwin]} {
+        set cmd "$name '$TESTDIR/tmp/a\\b/"
+        assert_complete_dir {g'} $cmd "$TESTDIR/tmp"
 
 
-            sync_after_int
-        }
+        sync_after_int
+    }
 
 
-        set cmd "$name 'a&b/"
-        assert_complete_dir {f'} $cmd "$::srcdir/fixtures/_filedir"
+    set cmd "$name 'a&b/"
+    assert_complete_dir {f'} $cmd "$::srcdir/fixtures/_filedir"
 
 
-        sync_after_int
+    sync_after_int
 
 
-        set cmd "$name \"ab/"; #"
-        assert_complete_dir {e"} $cmd "$::srcdir/fixtures/_filedir"; #"
+    set cmd "$name \"ab/"; #"
+    assert_complete_dir {e"} $cmd "$::srcdir/fixtures/_filedir"; #"
 
 
-        sync_after_int
+    sync_after_int
 
 
-        set cmd "$name \"a b/"; #"
-        assert_complete_dir {i"} $cmd "$::srcdir/fixtures/_filedir"; #"
+    set cmd "$name \"a b/"; #"
+    assert_complete_dir {i"} $cmd "$::srcdir/fixtures/_filedir"; #"
 
 
-        sync_after_int
+    sync_after_int
 
 
-        set cmd "$name \"a'b/"; #"
-        assert_complete_dir {c"} $cmd "$::srcdir/fixtures/_filedir"; #"
+    set cmd "$name \"a'b/"; #"
+    assert_complete_dir {c"} $cmd "$::srcdir/fixtures/_filedir"; #"
 
 
-        sync_after_int
+    sync_after_int
 
 
-        set cmd "$name \"a\\\"b/"; #"
-        assert_complete_dir {d"} $cmd "$::srcdir/fixtures/_filedir"; #"
+    set cmd "$name \"a\\\"b/"; #"
+    assert_complete_dir {d"} $cmd "$::srcdir/fixtures/_filedir"; #"
 
 
-        sync_after_int
+    sync_after_int
 
 
-        set cmd "$name \"a\\\$b/"; #"
-        assert_complete_dir "\b\b\b\b\b$::srcdirabs/fixtures/_filedir/a\\\\\$b/h\\\"" $cmd "$::srcdir/fixtures/_filedir"
+    set cmd "$name \"a\\\$b/"; #"
+    assert_complete_dir "\b\b\b\b\b$::srcdirabs/fixtures/_filedir/a\\\\\$b/h\\\"" $cmd "$::srcdir/fixtures/_filedir"
 
 
-        sync_after_int
+    sync_after_int
 
 
-        set cmd "$name \"a\\b/"; #"
-        assert_complete_dir "\b\b\bb/e\\\"" $cmd "$::srcdir/fixtures/_filedir"
+    set cmd "$name \"a\\b/"; #"
+    assert_complete_dir "\b\b\bb/e\\\"" $cmd "$::srcdir/fixtures/_filedir"
 
 
-        sync_after_int
+    sync_after_int
 
 
-        set cmd "$name \"a\\\\b/"; #"
-        assert_complete_dir {g"} $cmd "$TESTDIR/tmp"; #"
+    set cmd "$name \"a\\\\b/"; #"
+    assert_complete_dir {g"} $cmd "$TESTDIR/tmp"; #"
 
 
-        sync_after_int
+    sync_after_int
 
 
-        set cmd "$name \"a&b/"; #"
-        assert_complete_dir {f"} $cmd "$::srcdir/fixtures/_filedir"; #"
+    set cmd "$name \"a&b/"; #"
+    assert_complete_dir {f"} $cmd "$::srcdir/fixtures/_filedir"; #"
 
 
-        sync_after_int
+    sync_after_int
 
 
-    }; # if 4.0.0 < bash-version > 4.0.34
 }; # foreach
 
 
@@ -249,13 +237,12 @@ sync_after_int
 
 
 set test "completing f aé should return g"
-# Execute this test only on bash >= 4 with LC_CTYPE matching *UTF-8*
+# Execute this test only with LC_CTYPE matching *UTF-8*
 # See also: http://www.mail-archive.com/bash-completion-devel\
 #           @lists.alioth.debian.org/msg02265.html
 # Don't execute this test on expect-5.44 cause it will segfault
 # See also: Alioth #312792
 if {
-    [lindex $::BASH_VERSINFO 0] >= 4 &&
     [string first "UTF-8" $::LC_CTYPE] != -1 &&
     [string first 5.44 [exp_version]] != 0
 } {
diff --git a/test/unit/_get_comp_words_by_ref.exp b/test/unit/_get_comp_words_by_ref.exp
index 9a12d8a..df2c531 100644
--- a/test/unit/_get_comp_words_by_ref.exp
+++ b/test/unit/_get_comp_words_by_ref.exp
@@ -97,27 +97,13 @@ sync_after_int
 
 
 set test {a 'b c|};  # | = cursor position
-if {
-    [lindex $::BASH_VERSINFO 0] == 4 && 
-    [lindex $::BASH_VERSINFO 1] == 0 &&
-    [lindex $::BASH_VERSINFO 2] < 35
-} {
-    set cmd {COMP_WORDS=(a "'" b c); COMP_CWORD=3}
-} else {
-    set cmd {COMP_WORDS=(a "'b c"); COMP_CWORD=1}
-}
+set cmd {COMP_WORDS=(a "'b c"); COMP_CWORD=1}
 append cmd {; COMP_LINE="a 'b c"; COMP_POINT=6; _get_comp_words_by_ref cur prev; echo "$cur $prev"}
 send "$cmd\r"
 expect -ex "$cmd\r\n"
 expect {
     -ex "'b c a\r\n/@" { pass "$test" }
-    -ex "c b\r\n/@" { 
-        if {
-            [lindex $::BASH_VERSINFO 0] == 4 &&
-            [lindex $::BASH_VERSINFO 1] == 0 &&
-            [lindex $::BASH_VERSINFO 2] < 35
-        } {xfail "$test"} {fail "$test"}
-    }
+    -ex "c b\r\n/@" { fail "$test" }
 }
 
 
@@ -125,15 +111,7 @@ sync_after_int
 
 
 set test {a "b c|};  #"# | = cursor position
-if {
-    [lindex $::BASH_VERSINFO 0] == 4 && 
-    [lindex $::BASH_VERSINFO 1] == 0 &&
-    [lindex $::BASH_VERSINFO 2] < 35
-} {
-    set cmd {COMP_WORDS=(a "\"" b c); COMP_CWORD=3}
-} else {
-    set cmd {COMP_WORDS=(a "\"b c"); COMP_CWORD=1}
-}
+set cmd {COMP_WORDS=(a "\"b c"); COMP_CWORD=1}
 append cmd {; COMP_LINE="a \"b c"; COMP_POINT=6}
 assert_bash_exec $cmd
 set cmd {_get_comp_words_by_ref cur prev; echo "$cur $prev"};
@@ -141,13 +119,7 @@ send "$cmd\r"
 expect -ex "$cmd\r\n"
 expect {
     -ex "\"b c a\r\n/@" { pass "$test" }
-    -ex "c b\r\n/@" {
-        if {
-            [lindex $::BASH_VERSINFO 0] == 4 &&
-            [lindex $::BASH_VERSINFO 1] == 0 &&
-            [lindex $::BASH_VERSINFO 2] < 35
-        } {xfail "$test"} {fail "$test"}
-    }
+    -ex "c b\r\n/@" { fail "$test" }
 }
 
 
@@ -155,13 +127,8 @@ sync_after_int
 
 
 set test {a b:c| with WORDBREAKS += :};  # | = cursor position
-if {[lindex $::BASH_VERSINFO 0] <= 3} {
-    set cmd {COMP_WORDS=(a "b:c"); COMP_CWORD=1}
-    set expected {"b:c a"}
-} else {
-    set cmd {add_comp_wordbreak_char :; COMP_WORDS=(a b : c); COMP_CWORD=3}
-    set expected {"c :"}
-}
+set cmd {add_comp_wordbreak_char :; COMP_WORDS=(a b : c); COMP_CWORD=3}
+set expected {"c :"}
 append cmd {; COMP_LINE='a b:c'; COMP_POINT=5}
 # NOTE: Split-send cmd to prevent backspaces (\008) in output
 assert_bash_exec $cmd $test
@@ -173,11 +140,7 @@ sync_after_int
 
 
 set test {a b:c| with WORDBREAKS -= :};  # | = cursor position
-if {[lindex $::BASH_VERSINFO 0] <= 3} {
-    set cmd {COMP_WORDS=(a "b:c"); COMP_CWORD=1}
-} else {
-    set cmd {COMP_WORDS=(a b : c); COMP_CWORD=3}
-}
+set cmd {COMP_WORDS=(a b : c); COMP_CWORD=3}
 append cmd {; COMP_LINE='a b:c'; COMP_POINT=5}
 assert_bash_exec $cmd $test
 set cmd {_get_comp_words_by_ref -n : cur prev; echo "$cur $prev"}
@@ -188,11 +151,7 @@ sync_after_int
 
 
 set test {a b c:| with WORDBREAKS -= :};  # | = cursor position
-if {[lindex $::BASH_VERSINFO 0] <= 3} {
-    set cmd {COMP_WORDS=(a b c:); COMP_CWORD=2}
-} else {
-    set cmd {COMP_WORDS=(a b c :); COMP_CWORD=3}
-}
+set cmd {COMP_WORDS=(a b c :); COMP_CWORD=3}
 append cmd {; COMP_LINE='a b c:'; COMP_POINT=6}
 assert_bash_exec $cmd $test
 set cmd {_get_comp_words_by_ref -n : cur prev; echo "$cur $prev"}
@@ -203,11 +162,7 @@ sync_after_int
 
 
 set test {a b:c | with WORDBREAKS -= :};  # | = cursor position
-if {[lindex $::BASH_VERSINFO 0] <= 3} {
-    set cmd {COMP_WORDS=(a b:c ''); COMP_CWORD=2}
-} else {
-    set cmd {COMP_WORDS=(a b : c ''); COMP_CWORD=4}
-}
+set cmd {COMP_WORDS=(a b : c ''); COMP_CWORD=4}
 append cmd {; COMP_LINE='a b:c '; COMP_POINT=6}
 assert_bash_exec $cmd $test
 set cmd {_get_comp_words_by_ref -n : cur prev; echo "$cur $prev"}
@@ -228,11 +183,7 @@ sync_after_int
 
 
 set test {a b::| with WORDBREAKS -= : should return b::};  # | = cursor position
-if {[lindex $::BASH_VERSINFO 0] <= 3} {
-    set cmd {COMP_WORDS=(a "b::"); COMP_CWORD=1}
-} else {
-    set cmd {COMP_WORDS=(a b ::); COMP_CWORD=2}
-}
+set cmd {COMP_WORDS=(a b ::); COMP_CWORD=2}
 append cmd {; COMP_LINE='a b::'; COMP_POINT=5}
 assert_bash_exec $cmd
 set cmd {_get_comp_words_by_ref -n : cur prev; echo "$cur $prev"}
@@ -264,14 +215,9 @@ assert_bash_list c $cmd $test
 sync_after_int
 
 
-set test {a b=c| should return b=c (bash-3) or c (bash-4)};  # | = cursor position
-if {[lindex $::BASH_VERSINFO] <= 3} {
-    set cmd {COMP_WORDS=(a "b=c"); COMP_CWORD=1}
-    set expected b=c
-} else {
-    set cmd {COMP_WORDS=(a b = c); COMP_CWORD=3}
-    set expected c
-}
+set test {a b=c| should return c};  # | = cursor position
+set cmd {COMP_WORDS=(a b = c); COMP_CWORD=3}
+set expected c
 append cmd {; COMP_LINE='a b=c'; COMP_POINT=5}
 assert_bash_exec $cmd
 set cmd {_get_comp_words_by_ref cur prev; echo "$cur"}
@@ -325,15 +271,7 @@ sync_after_int
 
 
 set test {a 'b&c| should return 'b&c};  # | = cursor position
-if {
-    [lindex $::BASH_VERSINFO 0] == 4 && 
-    [lindex $::BASH_VERSINFO 1] == 0 &&
-    [lindex $::BASH_VERSINFO 2] < 35
-} {
-    set cmd {COMP_WORDS=(a "'" b "&" c); COMP_CWORD=4}
-} else {
-    set cmd {COMP_WORDS=(a "'b&c"); COMP_CWORD=1}
-}
+set cmd {COMP_WORDS=(a "'b&c"); COMP_CWORD=1}
 append cmd {; COMP_LINE="a 'b&c"; COMP_POINT=6}
 assert_bash_exec $cmd
 set cmd {_get_comp_words_by_ref cur prev; printf %s "$cur"}
@@ -341,13 +279,7 @@ send "$cmd\r"
 expect -ex "$cmd\r\n"
 expect {
     -ex "'b&c/@" { pass "$test" }
-    -ex "c/@" { 
-        if {
-            [lindex $::BASH_VERSINFO 0] == 4 &&
-            [lindex $::BASH_VERSINFO 1] == 0 &&
-            [lindex $::BASH_VERSINFO 2] < 35
-        } {xfail "$test"} {fail "$test"}
-    }
+    -ex "c/@" { fail "$test" }
 }
 
 
@@ -409,11 +341,7 @@ sync_after_int
 
 
 set test {a b: c| with WORDBREAKS -= :};  # | = cursor position
-if {[lindex $::BASH_VERSINFO 0] <= 3} {
-    set cmd {COMP_WORDS=(a b: c); COMP_CWORD=2}
-} else {
-    set cmd {COMP_WORDS=(a b : c); COMP_CWORD=3}
-}
+set cmd {COMP_WORDS=(a b : c); COMP_CWORD=3}
 append cmd {; COMP_LINE='a b: c'; COMP_POINT=6}
 assert_bash_exec $cmd $test
 set cmd {_get_comp_words_by_ref -n : words; echo "${words[@]}"}
@@ -424,11 +352,7 @@ sync_after_int
 
 
 set test {a b :c| with WORDBREAKS -= :};  # | = cursor position
-if {[lindex $::BASH_VERSINFO 0] <= 3} {
-    set cmd {COMP_WORDS=(a b :c); COMP_CWORD=2}
-} else {
-    set cmd {COMP_WORDS=(a b : c); COMP_CWORD=3}
-}
+set cmd {COMP_WORDS=(a b : c); COMP_CWORD=3}
 append cmd {; COMP_LINE='a b :c'; COMP_POINT=6}
 assert_bash_exec $cmd $test
 set cmd {_get_comp_words_by_ref -n : words; echo "${words[@]}"}
@@ -439,11 +363,7 @@ sync_after_int
 
 
 set test {a b\ :c| with WORDBREAKS -= :};  # | = cursor position
-if {[lindex $::BASH_VERSINFO 0] <= 3} {
-    set cmd {COMP_WORDS=(a "b\\ :c"); COMP_CWORD=1}
-} else {
-    set cmd {COMP_WORDS=(a "b\\ " : c); COMP_CWORD=3}
-}
+set cmd {COMP_WORDS=(a "b\\ " : c); COMP_CWORD=3}
 append cmd {; COMP_LINE='a b\ :c'; COMP_POINT=7}
 assert_bash_exec $cmd $test
 set cmd {_get_comp_words_by_ref -n : words; echo "${words[@]}"}
diff --git a/test/unit/_get_cword.exp b/test/unit/_get_cword.exp
index ce749ce..3a58281 100644
--- a/test/unit/_get_cword.exp
+++ b/test/unit/_get_cword.exp
@@ -97,27 +97,13 @@ sync_after_int
 
 
 set test {a 'b c| should return 'b c};  # | = cursor position
-if {
-    [lindex $::BASH_VERSINFO 0] == 4 && 
-    [lindex $::BASH_VERSINFO 1] == 0 &&
-    [lindex $::BASH_VERSINFO 2] < 35
-} {
-    set cmd {COMP_WORDS=(a "'" b c); COMP_CWORD=3}
-} else {
-    set cmd {COMP_WORDS=(a "'b c"); COMP_CWORD=1}
-}
+set cmd {COMP_WORDS=(a "'b c"); COMP_CWORD=1}
 append cmd {; COMP_LINE="a 'b c"; COMP_POINT=6; _get_cword}
 send "$cmd\r"
 expect -ex "$cmd\r\n"
 expect {
     -ex "'b c/@" { pass "$test" }
-    -ex "c/@" { 
-        if {
-            [lindex $::BASH_VERSINFO 0] == 4 &&
-            [lindex $::BASH_VERSINFO 1] == 0 &&
-            [lindex $::BASH_VERSINFO 2] < 35
-        } {xfail "$test"} {fail "$test"}
-    }
+    -ex "c/@" { fail "$test" }
 }
 
 
@@ -125,41 +111,22 @@ sync_after_int
 
 
 set test {a "b c| should return "b c};  # | = cursor position
-if {
-    [lindex $::BASH_VERSINFO 0] == 4 && 
-    [lindex $::BASH_VERSINFO 1] == 0 &&
-    [lindex $::BASH_VERSINFO 2] < 35
-} {
-    set cmd {COMP_WORDS=(a "\"" b c); COMP_CWORD=3}
-} else {
-    set cmd {COMP_WORDS=(a "\"b c"); COMP_CWORD=1}
-}
+set cmd {COMP_WORDS=(a "\"b c"); COMP_CWORD=1}
 append cmd {; COMP_LINE="a \"b c"; COMP_POINT=6; _get_cword};
 send "$cmd\r"
 expect -ex "$cmd\r\n"
 expect {
     -ex "\"b c/@" { pass "$test" }
-    -ex "c/@" {
-        if {
-            [lindex $::BASH_VERSINFO 0] == 4 &&
-            [lindex $::BASH_VERSINFO 1] == 0 &&
-            [lindex $::BASH_VERSINFO 2] < 35
-        } {xfail "$test"} {fail "$test"}
-    }
+    -ex "c/@" { fail "$test" }
 }
 
 
 sync_after_int
 
 
-set test {a b:c| with WORDBREAKS += : should return b:c (bash-3) or c (bash-4)};  # | = cursor position
-if {[lindex $::BASH_VERSINFO 0] <= 3} {
-    set cmd {COMP_WORDS=(a "b:c"); COMP_CWORD=1}
-    set expected b:c
-} else {
-    set cmd {add_comp_wordbreak_char :; COMP_WORDS=(a b : c); COMP_CWORD=3}
-    set expected c
-}
+set test {a b:c| with WORDBREAKS += : should return c};  # | = cursor position
+set cmd {add_comp_wordbreak_char :; COMP_WORDS=(a b : c); COMP_CWORD=3}
+set expected c
 append cmd {; COMP_LINE='a b:c'; COMP_POINT=5; _get_cword; echo}
 assert_bash_list $expected $cmd $test
 
@@ -168,11 +135,7 @@ sync_after_int
 
 
 set test {a b:c| with WORDBREAKS -= : should return b:c};  # | = cursor position
-if {[lindex $::BASH_VERSINFO 0] <= 3} {
-    set cmd {COMP_WORDS=(a "b:c"); COMP_CWORD=1}
-} else {
-    set cmd {COMP_WORDS=(a b : c); COMP_CWORD=3}
-}
+set cmd {COMP_WORDS=(a b : c); COMP_CWORD=3}
 append cmd {; COMP_LINE='a b:c'; COMP_POINT=5; _get_cword :; echo}
 assert_bash_list b:c $cmd $test
 
@@ -181,11 +144,7 @@ sync_after_int
 
 
 set test {a b c:| with WORDBREAKS -= : should return c:};  # | = cursor position
-if {[lindex $::BASH_VERSINFO 0] <= 3} {
-    set cmd {COMP_WORDS=(a b c:); COMP_CWORD=2}
-} else {
-    set cmd {COMP_WORDS=(a b c :); COMP_CWORD=3}
-}
+set cmd {COMP_WORDS=(a b c :); COMP_CWORD=3}
 append cmd {; COMP_LINE='a b c:'; COMP_POINT=6; _get_cword :; echo}
 assert_bash_list c: $cmd $test
 
@@ -202,11 +161,7 @@ sync_after_int
 
 
 set test {a b::| with WORDBREAKS -= : should return b::};  # | = cursor position
-if {[lindex $::BASH_VERSINFO 0] <= 3} {
-    set cmd {COMP_WORDS=(a "b::"); COMP_CWORD=1}
-} else {
-    set cmd {COMP_WORDS=(a b ::); COMP_CWORD=2}
-}
+set cmd {COMP_WORDS=(a b ::); COMP_CWORD=2}
 append cmd {; COMP_LINE='a b::'; COMP_POINT=5; _get_cword :; echo}
 assert_bash_list b:: $cmd $test
 
@@ -232,14 +187,9 @@ assert_bash_list c $cmd $test
 sync_after_int
 
 
-set test {a b=c| should return b=c (bash-3) or c (bash-4)};  # | = cursor position
-if {[lindex $::BASH_VERSINFO] <= 3} {
-    set cmd {COMP_WORDS=(a "b=c"); COMP_CWORD=1}
-    set expected b=c
-} else {
-    set cmd {COMP_WORDS=(a b = c); COMP_CWORD=3}
-    set expected c
-}
+set test {a b=c| should return c};  # | = cursor position
+set cmd {COMP_WORDS=(a b = c); COMP_CWORD=3}
+set expected c
 append cmd {; COMP_LINE='a b=c'; COMP_POINT=5; _get_cword; echo}
 assert_bash_list $expected $cmd $test
 
@@ -286,27 +236,13 @@ sync_after_int
 
 
 set test {a 'b&c| should return 'b&c};  # | = cursor position
-if {
-    [lindex $::BASH_VERSINFO 0] == 4 && 
-    [lindex $::BASH_VERSINFO 1] == 0 &&
-    [lindex $::BASH_VERSINFO 2] < 35
-} {
-    set cmd {COMP_WORDS=(a "'" b "&" c); COMP_CWORD=4}
-} else {
-    set cmd {COMP_WORDS=(a "'b&c"); COMP_CWORD=1}
-}
+set cmd {COMP_WORDS=(a "'b&c"); COMP_CWORD=1}
 append cmd {; COMP_LINE="a 'b&c"; COMP_POINT=6; _get_cword}
 send "$cmd\r"
 expect -ex "$cmd\r\n"
 expect {
     -ex "'b&c/@" { pass "$test" }
-    -ex "c/@" { 
-        if {
-            [lindex $::BASH_VERSINFO 0] == 4 &&
-            [lindex $::BASH_VERSINFO 1] == 0 &&
-            [lindex $::BASH_VERSINFO 2] < 35
-        } {xfail "$test"} {fail "$test"}
-    }
+    -ex "c/@" { fail "$test" }
 }
 
 
diff --git a/test/unit/compgen.exp b/test/unit/compgen.exp
index 6e6f79c..9fc1efb 100644
--- a/test/unit/compgen.exp
+++ b/test/unit/compgen.exp
@@ -11,31 +11,15 @@ proc teardown {} {
 setup
 
 
-if {[lindex $::BASH_VERSINFO 0] <= 3} {
-    set test {compgen -f a\\\\\\\'b/ on bash-3 should return a\'b/c};
-    set cmd {compgen -f a\\\\\\\'b/}
-} else {
-    set test {compgen -f a\\\'b/ on bash-4 should return a\'b/c};
-    set cmd {compgen -f a\\\'b/}
-}
+set test {compgen -f a\\\'b/ should return a\'b/c}
+set cmd {compgen -f a\\\'b/}
 set dir $::srcdir/fixtures/compgen
 assert_bash_exec "cd $dir"
 send "$cmd\r"
 expect -ex "$cmd\r\n"
 expect {
-    -re {a\\\'b/c} {
-        # On bash-3.2, compgen returns inconsequent output
-        if {
-            [lindex $::BASH_VERSINFO 0] >= 4 || (
-                [lindex $::BASH_VERSINFO 0] == 3 &&
-                [lindex $::BASH_VERSINFO 1] == 2
-            )
-        } {pass $test} else {fail $test}
-    }
-    -re {a'b/c} {
-        if {[lindex $::BASH_VERSINFO 0] <= 3 } \
-            {pass $test} else {fail $test}
-    }
+    -re {a\\\'b/c} { pass $test }
+    -re {a'b/c} { fail $test }
     -re /@ { pass "$test" }
     -re eof { unresolved "eof" }
 }

-- 
bash-completion



More information about the Bash-completion-commits mailing list