From 4fa2616e70a4c0dda96aa995d96211261731a992 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Sun, 11 Dec 2011 22:23:06 +0200 Subject: [PATCH] Document $split && return. --- doc/styleguide.txt | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/doc/styleguide.txt b/doc/styleguide.txt index 12b224f1..31ad4469 100644 --- a/doc/styleguide.txt +++ b/doc/styleguide.txt @@ -75,6 +75,26 @@ appended after the equal sign. Calling compopt -o nospace makes sense in case completion actually occurs: when only one completion is available in COMPREPLY. +$split && return +---------------- + +Should be used in completions using the -s flag of _init_completion, +or other similar cases where _split_longopt has been invoked, after +$prev has been managed but before $cur is considered. If $cur of the +form --foo=bar was split into $prev=--foo and $cur=bar and the $prev +block did not process the option argument completion, it makes sense +to return immediately after the $prev block because --foo obviously +takes an argument and the remainder of the completion function is +unlikely to provide meaningful results for the required argument. +Think of this as a catch-all for unknown options requiring an +argument. + +Note that even when using this, options that are known to require an +argument but for which we don't have argument completion should be +explicitly handled (non-completed) in the $prev handling block because +--foo=bar options can often be written without the equals sign, and in +that case the long option splitting does not occur. + ///////////////////////////////////////// case/esac vs if ---------------