[Bash-completion-devel] wget(1) completion
Igor Murzov
e-mail at date.by
Wed Sep 5 12:14:31 UTC 2012
On Wed, 5 Sep 2012 13:01:14 +0200
"Raphaël Droz" <raphael.droz at gmail.com> wrote:
> On Sun, Jul 22, 2012 at 03:14:28PM +0400, Igor Murzov wrote:
> > This completion looks good to me and I'd like to merge
> > it in. Please fix formating (no tabs, 80-column wrapping)
> > and prepare the patch. I know that you have a mirror of
> > bash-completion, but it doesn't have any branch that can
> > be merged -- wget related commits are distributed in your
> > master branch. So please create separate branch on top of
> > the origin/master for your wget related commits.
>
> I can't get indentation done correctly with emacs 23 or 24. I'll provide
> a new file as soon as it get this sorted.
How could this happen? You have Emacs indentation settings
in this very file. Anyway, you can fix it with sed easily.
> I'm answering below anyway.
>
> >
> > Some remarks:
> >
> > * Emacs indentation setting in the bottom should be removed.
>
> right, a simple
> > ex: ts=4 sw=4 et filetype=sh
> is ok though ?
Yes.
> > * Following code:
> >
> > ----------------------------------------------
> > # prevopt is the previous options string used as a prefix
> > # to avoid COMPREPLY replacing them with the $lastopt completion
> > local lastopt=${cur/*,} prevopt=
> > [[ $cur = *, ]] && prevopt=${cur%,*},
> > ----------------------------------------------
> >
> > doesn't work. It's probably enough to replace '$cur = *,'
> > with '$cur = *,*' to fix it.
>
>
> confirmed... but strange I didn't noticed it
>
>
> > * I'm not sure if it is useful to add '-' to $COMPREPLY:
> >
> > [[ $cur = -* || -z $cur ]] && COMPREPLY+=( - )
> >
> > We don't even complete short options, so no need to
> > complete something that is one character wide.
>
> I myself use a lot wget -O - (in fact I even have `owget`) so it's more
> about the `hint` for users at no cost as it shouldn't disturb typing.
> ( we do complete one-letter filenames )
Ok.
> > *
> > ----------------------------------------------
> > --tries|--dns-timeout|--connect-timeout|--timeout|--limit-rate|\
> > --wait|--waitretry|--cut-dirs|--max-redirect)
> > COMPREPLY=( $( compgen -W "{0..9}" -- $cur ) )
> > ----------------------------------------------
> >
> > 9 seconds at most is not enough for timeouts.
>
> Again it's more about "hinting" rather than completing.
> One solution would be to provide as much numbers as permit $COLUMNS in
> order to fill 1 line only, so something like:
> a=(( ($COLUMNS-20) / 3 + 10 ))
> $( compgen -W "{1..$a}" ) # if a bash-syntax exists for this
I think you can either set more reasonable maximum here:
COMPREPLY=( $( compgen -W "{0..180}" -- $cur ) )
Or complete any integer number like this:
COMPREPLY+=( $( compgen -W '{0..9}' ) )
compopt -o nospace
> > *
> > ----------------------------------------------
> > --quota)
> > COMPREPLY=( $( compgen -W "{0..9}{k,m}" -- $cur ) )
> > ----------------------------------------------
> >
> > same thing here.
>
> maybe "inf 0 {1..9}{k,m}" is better, but I can't think about a perfect
> "typing-oriented" solution.
> It's more a "hinting-oriented" completion.
> any idea ?
Maybe something like this:
COMPREPLY=( $( compgen -W '0 {1..102}0{,k,m}' ) )
? But it would be fine if there would be no completion for
--quota|-Q at all :)
> [ I also missed |-Q completion ]
>
>
> > * No need to be clever trying to keep user from doing
> > something that he wants to do:
> >
> > # avoid accidentally overwriting files: suggest directories only
>
> since I discovered bash filename completion Alt+/ I really think that
> bash-completion should be clever on file completion.
> One wanting to overwrite may perfectly use Alt+/ which will blindly
> complete the filename.
> With a simple <tab> it's really the path to <enter> is way too easy if
> there is a risk of file removal.
> At the very least this precaution could be dropped for cookies.
>
> This behavior does not match the needs for --default-page, I'll change
> that too.
Not everyone aware of Alt+/. Also being too clever can
make people angry. People doesn't like to be outsmarted
by their own system :)
> > * This one is too smart:
> >
> > # +o nospace when no more valid option is possible (= append a space)
> >
> > let's drop this part.
>
> why ? it's sooooooo smart, and only cost 1 subshell when completing
> --restrict-file-names only.
> does it disturb ?
Fine.
> > * Completion script shouldn't spew tons of error messages
> > if something goes wrong, so don't forget to append
> > '2>/dev/null' every time you run some external tool like
> > iconv or sed.
>
> will do this for the sed ~/.netrc instance (risk of non-existence).
> The other one and iconv -l shouldn't output anything to stderr.
Ok.
> I'll push a new version as soon as I can get emacs to indent correctly
> this file.
It would be nice if you make new version available in its
own topic branch based on 'origin/master'.
-- Igor
More information about the Bash-completion-devel
mailing list