[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[PATCH] bash_completion glob confusion

From: Peter Samuelson <peter_at_p12n.org>
Date: 2005-12-05 12:17:16 CET

bash completion for 'svn <tab>' tries to include "?" as a subcommand.
This doesn't work, at least in bash 3.0, because the bash completion
machinery somehow thinks it is a glob, and lists all single-character
filenames in the current directory. Thus it will only do the right
thing _if_ you have no files that match "?".

So perhaps 'svn ?' could be fixed, but I don't think it's worth it:

- The completion code would have to replace ? with \? or '?' or "?",
  lest the shell treat it as a glob later anyway.

- It's a single-character synonym for a perfectly intuitive command
  and thus doesn't need completion support. Let the user type
  "svn h<tab>" or "svnadmin he<tab>" instead.

[The LC_ALL=C at the top of bash_completion_test is unrelated, but I
needed it: the test script requires 'svn help' output to be in English.
I'm on a GNU libc platform; I don't know what the equivalent fix would
be on Cygwin and other arbitrary non-POSIX platforms.]

[[[
Remove bash completion support for "svn ?" and "svnadmin ?", which
interact badly with file globbing.

Patch by: Peter Samuelson <peter@p12n.org>

* tools/client-side/bash_completion:
    Remove "?" from the lists of svn and svnadmin subcommands.

* tools/client-side/bash_completion_test:
    Ignore "?" in subcommand autodetection.
    Also override locale settings to prevent spurious test failures.
]]]

Index: tools/client-side/bash_completion_test
===================================================================
--- tools/client-side/bash_completion_test (revisione 17602)
+++ tools/client-side/bash_completion_test (copia locale)
@@ -12,6 +12,7 @@
 
 set -e # Exit on error
 shopt -s extglob
+export LC_ALL=C
 
 # Execute the script which is to be tested.
 . "$1"
@@ -75,16 +76,16 @@
     # Remove simple abbreviations
     ( while read SYNONYMS; do
         for CMD in $SYNONYMS; do
- for SYNONYM in $SYNONYMS; do
- if [ $CMD != "?" ]; then
+ if [ "$CMD" != "?" ]; then
+ for SYNONYM in $SYNONYMS; do
               case $SYNONYM in
               $CMD) ;;
               $CMD*) CMD= ; break ;;
               esac
+ done
+ if [ $CMD ]; then
+ echo $CMD
             fi
- done
- if [ $CMD ]; then
- echo $CMD
           fi
         done
       done
@@ -115,8 +116,6 @@
 
 echo "Checking general completion"
 includes "he" "help"
-includes "" "?"
-includes "" "h"
 includes "" "help"
 includes "" "--version"
 
Index: tools/client-side/bash_completion
===================================================================
--- tools/client-side/bash_completion (revisione 17602)
+++ tools/client-side/bash_completion (copia locale)
@@ -41,7 +41,7 @@
 
         # Possible expansions, without pure-prefix abbreviations such as "up".
         cmds='add blame annotate praise cat checkout co cleanup commit ci \
- copy cp delete remove rm diff export help ? import info \
+ copy cp delete remove rm diff export help import info \
               list ls lock log merge mkdir move mv rename \
               propdel pdel propedit pedit propget pget \
               proplist plist propset pset resolved revert \
@@ -612,7 +612,7 @@
         cur=${COMP_WORDS[COMP_CWORD]}
 
         # Possible expansions, without pure-prefix abbreviations such as "h".
- cmds='create deltify dump help ? hotcopy list-dblogs \
+ cmds='create deltify dump help hotcopy list-dblogs \
               list-unused-dblogs load lslocks lstxns recover rmlocks \
               rmtxns setlog verify --version'
 

Received on Mon Dec 5 12:22:06 2005

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.