[Bash-completion-devel] wget(1) completion
Raphaël Droz
raphael.droz at gmail.com
Wed Sep 5 11:01:14 UTC 2012
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.
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 ?
> * 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 )
> *
> ----------------------------------------------
> --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
> *
> ----------------------------------------------
> --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 ?
[ 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.
> * 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 ?
> * 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.
I'll push a new version as soon as I can get emacs to indent correctly
this file.
best regards
More information about the Bash-completion-devel
mailing list