File tree 1 file changed +16
-9
lines changed
1 file changed +16
-9
lines changed Original file line number Diff line number Diff line change @@ -90,20 +90,25 @@ func cli(shell *nash.Shell) error {
90
90
91
91
func docli (shell * nash.Shell , rline * readline.Instance ) error {
92
92
var (
93
- content bytes.Buffer
94
- lineidx int
95
- line string
96
- parse * parser.Parser
97
- tr * ast.Tree
98
- err error
93
+ content bytes.Buffer
94
+ lineidx int
95
+ line string
96
+ parse * parser.Parser
97
+ tr * ast.Tree
98
+ err error
99
+ unfinished bool
100
+ prompt string
99
101
)
100
102
101
103
for {
102
- if fn , ok := shell .GetFn ("nash_repl_before" ); ok {
104
+ if fn , ok := shell .GetFn ("nash_repl_before" ); ok && ! unfinished {
103
105
execFn (shell , fn )
104
106
}
105
107
106
- prompt := shell .Prompt ()
108
+ if ! unfinished {
109
+ prompt = shell .Prompt ()
110
+ }
111
+
107
112
rline .SetPrompt (prompt )
108
113
109
114
line , err = rline .Readline ()
@@ -160,6 +165,7 @@ func docli(shell *nash.Shell, rline *readline.Instance) error {
160
165
goto cont
161
166
} else if errBlock , ok := err .(BlockNotFinished ); ok && errBlock .Unfinished () {
162
167
prompt = ">>> "
168
+ unfinished = true
163
169
goto cont
164
170
}
165
171
@@ -169,6 +175,7 @@ func docli(shell *nash.Shell, rline *readline.Instance) error {
169
175
goto cont
170
176
}
171
177
178
+ unfinished = false
172
179
content .Reset ()
173
180
174
181
_ , err = shell .ExecuteTree (tr )
@@ -178,7 +185,7 @@ func docli(shell *nash.Shell, rline *readline.Instance) error {
178
185
}
179
186
180
187
cont:
181
- if fn , ok := shell .GetFn ("nash_repl_after" ); ok {
188
+ if fn , ok := shell .GetFn ("nash_repl_after" ); ok && ! unfinished {
182
189
var status sh.Obj
183
190
var ok bool
184
191
You can’t perform that action at this time.
0 commit comments