Skip to content

Commit a7afaee

Browse files
committed
exit with error when --batch arg is empty string
rather than silently ignoring --batch and entering the REPL. We must use a None test rather than a general truthiness test.
1 parent ba0435f commit a7afaee

3 files changed

Lines changed: 5 additions & 4 deletions

File tree

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Bug Fixes
1616
* Better completions refresh on changing databases or ALTERs.
1717
* Make the return value of `FavoriteQueries.list()` a copy.
1818
* Make multi-line detection and special cases more robust.
19+
* Exit with error when the `--batch` argument is an empty string.
1920

2021

2122
Internal

mycli/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2689,10 +2689,10 @@ def get_password_from_file(password_file: str | None) -> str | None:
26892689
click.secho(str(e), err=True, fg="red")
26902690
sys.exit(1)
26912691

2692-
if cli_args.batch and cli_args.batch != '-' and cli_args.progress and sys.stderr.isatty():
2692+
if cli_args.batch is not None and cli_args.batch != '-' and cli_args.progress and sys.stderr.isatty():
26932693
sys.exit(main_batch_with_progress_bar(mycli, cli_args))
26942694

2695-
if cli_args.batch:
2695+
if cli_args.batch is not None:
26962696
sys.exit(main_batch_without_progress_bar(mycli, cli_args))
26972697

26982698
if not sys.stdin.isatty():

mycli/main_modes/batch.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def dispatch_batch_statements(
6262

6363
def main_batch_with_progress_bar(mycli: 'MyCli', cli_args: 'CliArgs') -> int:
6464
goal_statements = 0
65-
if not cli_args.batch:
65+
if cli_args.batch is None:
6666
return 1
6767
if not sys.stdin.isatty() and cli_args.batch != '-':
6868
click.secho('Ignoring STDIN since --batch was also given.', err=True, fg='yellow')
@@ -108,7 +108,7 @@ def main_batch_with_progress_bar(mycli: 'MyCli', cli_args: 'CliArgs') -> int:
108108

109109

110110
def main_batch_without_progress_bar(mycli: 'MyCli', cli_args: 'CliArgs') -> int:
111-
if not cli_args.batch:
111+
if cli_args.batch is None:
112112
return 1
113113
if not sys.stdin.isatty() and cli_args.batch != '-':
114114
click.secho('Ignoring STDIN since --batch was also given.', err=True, fg='red')

0 commit comments

Comments
 (0)