summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorromkatv <roman.perepelitsa@gmail.com>2020-01-11 13:45:23 +0300
committerromkatv <roman.perepelitsa@gmail.com>2020-01-11 13:45:23 +0300
commitb8c9e836610cc7874d5c27d2a2276f9735220a36 (patch)
treec9d8b15a6eab3607011017fc227d7471a53e4ead /internal
parent57b500d083097fa796173b172e3b0cb4fbd3e1e8 (diff)
fix a few bugs in parsing
Diffstat (limited to 'internal')
-rw-r--r--internal/parse.zsh20
1 files changed, 20 insertions, 0 deletions
diff --git a/internal/parse.zsh b/internal/parse.zsh
index ba18a2dd..472f5588 100644
--- a/internal/parse.zsh
+++ b/internal/parse.zsh
@@ -21,6 +21,9 @@ typeset -gA _p9k_skip_token=(
'while' ''
'until' ''
'do' ''
+ 'done' ''
+ 'esac' ''
+ 'end' ''
'coproc' ''
'nocorrect' ''
'time' ''
@@ -45,6 +48,7 @@ typeset -gA _p9k_skip_token=(
'>>&' '*'
'&>>|' '*'
'>>|' '*'
+ 'foreach' '\(*\)'
)
typeset -gA _p9k_redirect=(
@@ -75,10 +79,25 @@ typeset -gA _p9k_term=(
';;' ''
';&' ''
';|' ''
+ '(' ''
')' ''
+ '{' ''
+ '}' ''
'()' ''
)
+# False positives:
+#
+# for x (y) z
+# {} always {}
+#
+# Completely broken:
+#
+# Setup:
+# setopt interactive_comments
+# alias x='#'
+# Punchline:
+# x; y
function _p9k_extract_commands() {
local rcquotes
[[ -o rcquotes ]] && rcquotes=(-o rcquotes)
@@ -183,6 +202,7 @@ function _p9k_extract_commands() {
fi
commands+=${:-${(Q)${~token}}}
+ [[ $commands[-1] == '(('*'))' ]] && commands[-1]=()
skip='^'
done