You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Peter Samuelson <pe...@p12n.org> on 2005/12/05 11:17:16 UTC
[PATCH] bash_completion glob confusion
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 <pe...@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'
Re: [PATCH] bash_completion glob confusion
Posted by Julian Foad <ju...@btopenworld.com>.
Michael W Thelen wrote:
> Peter Samuelson wrote:
>
>>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 "?".
>
> Thanks for the patch... is any developer able to take a look at this?
> If not, I'll file a patch for it in a day or two.
Another easy little patch ... that'll be one for me, then.
OK, the patch is fine. Committed in r18062, with the log message tweaked.
Thanks, Peter.
- Julian
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: [PATCH] bash_completion glob confusion
Posted by Michael W Thelen <mi...@pietdepsi.com>.
Peter Samuelson wrote:
> 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 "?".
Thanks for the patch... is any developer able to take a look at this?
If not, I'll file a patch for it in a day or two.
--
Michael W Thelen
It is a mistake to think you can solve any major problems just with
potatoes. -- Douglas Adams
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org