diff --git a/changelog.md b/changelog.md index 8ce9ec51..b49138b4 100644 --- a/changelog.md +++ b/changelog.md @@ -17,6 +17,7 @@ Bug Fixes * Make the return value of `FavoriteQueries.list()` a copy. * Make multi-line detection and special cases more robust. * Run empty `--execute` arguments instead of ignoring the flag. +* Exit with error when the `--batch` argument is an empty string. Internal diff --git a/mycli/main.py b/mycli/main.py index 7be94a5d..cb2890f6 100755 --- a/mycli/main.py +++ b/mycli/main.py @@ -2664,10 +2664,10 @@ def get_password_from_file(password_file: str | None) -> str | None: if cli_args.execute is not None: sys.exit(main_execute_from_cli(mycli, cli_args)) - if cli_args.batch and cli_args.batch != '-' and cli_args.progress and sys.stderr.isatty(): + if cli_args.batch is not None and cli_args.batch != '-' and cli_args.progress and sys.stderr.isatty(): sys.exit(main_batch_with_progress_bar(mycli, cli_args)) - if cli_args.batch: + if cli_args.batch is not None: sys.exit(main_batch_without_progress_bar(mycli, cli_args)) if not sys.stdin.isatty(): diff --git a/mycli/main_modes/batch.py b/mycli/main_modes/batch.py index 03b18207..c73296c7 100644 --- a/mycli/main_modes/batch.py +++ b/mycli/main_modes/batch.py @@ -62,7 +62,7 @@ def dispatch_batch_statements( def main_batch_with_progress_bar(mycli: 'MyCli', cli_args: 'CliArgs') -> int: goal_statements = 0 - if not cli_args.batch: + if cli_args.batch is None: return 1 if not sys.stdin.isatty() and cli_args.batch != '-': 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: def main_batch_without_progress_bar(mycli: 'MyCli', cli_args: 'CliArgs') -> int: - if not cli_args.batch: + if cli_args.batch is None: return 1 if not sys.stdin.isatty() and cli_args.batch != '-': click.secho('Ignoring STDIN since --batch was also given.', err=True, fg='red')