Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve ctrl-c exit
Browse files Browse the repository at this point in the history
Avoid displaying stack-tracke on Ctrl-C and return standard exit
code 130 for this case.
ssbarnea committed Mar 6, 2021
1 parent b0bfc1c commit 2b3b247
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/ansiblelint/__main__.py
Original file line number Diff line number Diff line change
@@ -42,7 +42,7 @@
render_yaml,
)
from ansiblelint.config import options, used_old_tags
from ansiblelint.constants import ANSIBLE_MISSING_RC
from ansiblelint.constants import ANSIBLE_MISSING_RC, EXIT_CRTL_RC
from ansiblelint.file_utils import cwd
from ansiblelint.skip_utils import normalize_tag
from ansiblelint.version import __version__
@@ -263,6 +263,8 @@ def _run_cli_entrypoint() -> None:
# NOTE: Only "broken pipe" is acceptable to ignore
if exc.errno != errno.EPIPE:
raise
except KeyboardInterrupt:
sys.exit(EXIT_CRTL_C)
except RuntimeError as e:
raise SystemExit(str(e))

1 change: 1 addition & 0 deletions src/ansiblelint/constants.py
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@
ANSIBLE_FAILURE_RC = 3
ANSIBLE_MISSING_RC = 4
INVALID_PREREQUISITES_RC = 10
EXIT_CRTL_RC = 130

# Minimal version of Ansible we support for runtime
ANSIBLE_MIN_VERSION = "2.9"

0 comments on commit 2b3b247

Please sign in to comment.