This commit is contained in:
Joe Bloggs 2014-03-27 15:44:34 +00:00
parent 7abd7c5999
commit dff3fe6d57
1 changed files with 15 additions and 8 deletions

View File

@ -300,14 +300,18 @@ Note that I have added an extra pattern for the initial command word itself.
Here is a more complex example where we call _regex_words for different words on the command line Here is a more complex example where we call _regex_words for different words on the command line
#+BEGIN_SRC sh #+BEGIN_SRC sh
local -a firstword firstword2 secondword secondword2 local -a firstword firstword2 secondword secondword2
_regex_words word 'The first word' 'word1a:a word:' 'word1b:b word:' 'word1c:c word' _regex_words word1 'The second word' 'woo:tang clan' 'hoo:not me'
firstword="$reply[@]" secondword=("$reply[@]")
_regex_words word 'Another first word' 'word11a:1a word:$secondword' 'word11b:1b word:$secondword' 'word11c:1c word:$secondword2' _regex_words word2 'Another second word' 'yee:thou' 'haa:very funny!'
firstword2="$reply[@]" secondword2=("$reply[@]")
_regex_words word 'The second word' 'word2a:a word' 'word2b:b word' 'word2c:c word' _regex_words commands 'The first word' 'foo:do foo' 'man:yeah man' 'chu:at chu'
secondword="$reply[@]" firstword=("$reply[@]")
_regex_words word 'Another second word' 'word22a:2a word' 'word22b:2b word' 'word22c:2c word' _regex_words word4 'Another first word' 'boo:scare somebody:$secondword' 'ga:baby noise:$secondword'\
secondword2="$reply[@]" 'loo:go to the toilet:$secondword2'
firstword2=("$reply[@]")
_regex_arguments _hello /$'[^\0]##\0'/ "${firstword[@]}" "${firstword2[@]}"
_hello "$@"
#+END_SRC #+END_SRC
@ -337,6 +341,9 @@ Take care to use the correct type of quoting for specifications to _arguments or
use double quotes if there is a parameter that needs to be expanded in the specification, single quotes otherwise, use double quotes if there is a parameter that needs to be expanded in the specification, single quotes otherwise,
and make sure to use different quotes around item descriptions. and make sure to use different quotes around item descriptions.
Check that you have the correct number of :'s in the correct places for specifications for _arguments,
_alternative, _regex_arguments, etc.
Remember to include an initial pattern to match the command word when using _regex_arguments (it does not need a matching action). Remember to include an initial pattern to match the command word when using _regex_arguments (it does not need a matching action).
* Putting it all together * Putting it all together
* Other resources * Other resources