Skip to content

Commit d2962bc

Browse files
committed
Avoid dbshell from closing upon error
1 parent 8719d28 commit d2962bc

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/yamcs/cli/dbshell.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,11 @@ def __init__(self, args):
4444
self.column_names = not args.skip_column_names
4545
self.binary_as_hex = not args.batch or args.binary_as_hex
4646
self.histfile = os.path.join(utils.CONFIG_DIR, "history")
47+
self.exit_on_error = False
4748

4849
if args.batch or args.command:
4950
self.histfile = None
51+
self.exit_on_error = True
5052

5153

5254
class DbShellCommand(utils.Command):
@@ -250,7 +252,7 @@ def print_topics(self, header, cmds, cmdlen, maxcol):
250252
print()
251253

252254
def emptyline(self):
253-
pass # Override default behaviour of repeating the last command
255+
return False # Override default behaviour of repeating the last command
254256

255257
def do_delimiter(self, args):
256258
"""(\\d) Set statement delimiter."""
@@ -301,8 +303,9 @@ def default(self, line):
301303
results = archive.execute_sql(statement)
302304
self.paginate(results)
303305
except YamcsError as e:
304-
eprint(e)
305-
sys.exit(1)
306+
eprint("\n".join("*** " + line for line in str(e).splitlines()))
307+
if self.opts.exit_on_error:
308+
sys.exit(1)
306309

307310
def run_command(self, command):
308311
if command == "\\":

0 commit comments

Comments
 (0)