Skip to content

Commit ff2d373

Browse files
authored
Merge pull request #1808 from dbcli/RW/respect-empty-batch-argument
Exit with error when the `--batch` argument is an empty string
2 parents 4ffaa3c + 626c25c commit ff2d373

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
@@ -17,6 +17,7 @@ Bug Fixes
1717
* Make the return value of `FavoriteQueries.list()` a copy.
1818
* Make multi-line detection and special cases more robust.
1919
* Run empty `--execute` arguments instead of ignoring the flag.
20+
* Exit with error when the `--batch` argument is an empty string.
2021

2122

2223
Internal

mycli/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2664,10 +2664,10 @@ def get_password_from_file(password_file: str | None) -> str | None:
26642664
if cli_args.execute is not None:
26652665
sys.exit(main_execute_from_cli(mycli, cli_args))
26662666

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

2670-
if cli_args.batch:
2670+
if cli_args.batch is not None:
26712671
sys.exit(main_batch_without_progress_bar(mycli, cli_args))
26722672

26732673
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)