Skip to content

Commit 488d4c0

Browse files
committed
Fresh SQL prompt when pressing enter if no input was provided
1 parent 787a2cb commit 488d4c0

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lib/rex/post/sql/ui/console/interactive_sql_client.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,16 @@ def _multiline
8484
::Reline.prompt_proc = proc { |line_buffer| line_buffer.each_with_index.map { |_line, i| i > 0 ? 'SQL *> ' : 'SQL >> ' } }
8585

8686
# We want to do this in a loop
87+
# multiline_input is the whole string that the user has input, not just the current line.
8788
raw_query = ::Reline.readmultiline('SQL >> ', use_history = true) do |multiline_input|
8889
# The user pressed ctrl + c or ctrl + z and wants to background our SQL prompt
8990
return { status: :exit, result: nil } unless self.interacting
91+
# When the user has pressed the enter key with no input, don't run any queries;
92+
# simply give them a new prompt on a new line.
93+
if multiline_input.chomp.empty?
94+
print_blank_line
95+
return { status: :success, result: nil }
96+
end
9097

9198
# In the case only a stop word was input, exit out of the REPL shell
9299
finished = (multiline_input.split.count == 1 && stop_words.include?(multiline_input.split.last))

0 commit comments

Comments
 (0)