Skip to content

Commit 666984d

Browse files
authored
Use sys.exit() instead of exit() (#568)
1 parent 02b6857 commit 666984d

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/dotenv/cli.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def stream_file(path: os.PathLike) -> Iterator[IO[str]]:
7777
yield stream
7878
except OSError as exc:
7979
print(f"Error opening env file: {exc}", file=sys.stderr)
80-
exit(2)
80+
sys.exit(2)
8181

8282

8383
@cli.command(name="list")
@@ -122,7 +122,7 @@ def set_value(ctx: click.Context, key: Any, value: Any) -> None:
122122
if success:
123123
click.echo(f"{key}={value}")
124124
else:
125-
exit(1)
125+
sys.exit(1)
126126

127127

128128
@cli.command()
@@ -139,7 +139,7 @@ def get(ctx: click.Context, key: Any) -> None:
139139
if stored_value:
140140
click.echo(stored_value)
141141
else:
142-
exit(1)
142+
sys.exit(1)
143143

144144

145145
@cli.command()
@@ -153,7 +153,7 @@ def unset(ctx: click.Context, key: Any) -> None:
153153
if success:
154154
click.echo(f"Successfully removed {key}")
155155
else:
156-
exit(1)
156+
sys.exit(1)
157157

158158

159159
@cli.command(context_settings={"ignore_unknown_options": True})
@@ -179,7 +179,7 @@ def run(ctx: click.Context, override: bool, commandline: List[str]) -> None:
179179

180180
if not commandline:
181181
click.echo("No command given.")
182-
exit(1)
182+
sys.exit(1)
183183
run_command(commandline, dotenv_as_dict)
184184

185185

@@ -213,6 +213,6 @@ def run_command(command: List[str], env: Dict[str, str]) -> None:
213213
p = Popen(command, universal_newlines=True, bufsize=0, shell=False, env=cmd_env)
214214
_, _ = p.communicate()
215215

216-
exit(p.returncode)
216+
sys.exit(p.returncode)
217217
else:
218218
os.execvpe(command[0], args=command, env=cmd_env)

0 commit comments

Comments
 (0)