summaryrefslogtreecommitdiffstats
path: root/ci
diff options
context:
space:
mode:
authordana <dana@dana.is>2017-07-06 19:15:56 -0500
committerAndrew Gallant <jamslam@gmail.com>2017-07-18 07:03:36 -0400
commit79ad81626f6089ad7009c1b1094f4beb686c070b (patch)
tree1f0b489750e47f2abf2c7129e09e3bdb211daafb /ci
parent354a5cad970453043fe25c2a184afc7808e235c2 (diff)
Update test_complete.sh to avoid false positives related to shell syntax
Diffstat (limited to 'ci')
-rwxr-xr-xci/test_complete.sh14
1 files changed, 11 insertions, 3 deletions
diff --git a/ci/test_complete.sh b/ci/test_complete.sh
index 5f00f79b..9b7f91fe 100755
--- a/ci/test_complete.sh
+++ b/ci/test_complete.sh
@@ -1,6 +1,10 @@
#!/bin/sh
+##
# Compares options in `rg --help` output to options in zsh completion function
+#
+# @todo If we could rely on zsh being installed we could change all of this to
+# simply source the completion-function file and pull the rg_args array out...
set -e
@@ -32,7 +36,8 @@ main() {
# 'Parse' options out of the completion-function file. To prevent false
# negatives, we:
#
- # * Exclude lines that look like comments
+ # * Exclude lines that don't start with punctuation expected of option
+ # definitions
# * Exclude lines that don't appear to have a bracketed description
# suitable for `_arguments`
# * Exclude those bracketed descriptions so we don't match options
@@ -48,8 +53,11 @@ main() {
# variables or command substitutions. Brace expansion is OK as long as
# each component of the expression is a complete option flag — in
# other words, `{--foo,--bar}` is valid, but `--{foo,bar}` is not
- "${rg}" -v -- '^\s*#' "${_rg}" |
- "${rg}" --replace '$1' -- '^.*?(?:\(.+?\).*?)?(-.+)\[.+\].*' |
+ # * Bracketed descriptions must contain at least two characters and must
+ # not begin with `!`, `@`, or `^` (in order to avoid confusion with
+ # shell syntax)
+ "${rg}" -- "^\s*[\"':({*-]" "${_rg}" |
+ "${rg}" --replace '$1' -- '^.*?(?:\(.+?\).*?)?(-.+)\[[^!@^].+\].*' |
tr -d "\t (){}*=+:'\"" |
tr ',' '\n' |
sort -u > "${compTemp}"