Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit06bd2c7

Browse files
committed
Omit CWD in executable search even when shell=True
1 parentc1f6c17 commit06bd2c7

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

‎git/cmd.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -985,23 +985,31 @@ def execute(
985985
ifinline_envisnotNone:
986986
env.update(inline_env)
987987

988+
ifshellisNone:
989+
shell=self.USE_SHELL
990+
991+
cmd_not_found_exception=FileNotFoundError
992+
maybe_patch_caller_env=contextlib.nullcontext()
993+
988994
ifos.name=="nt":
989-
cmd_not_found_exception=OSError
990995
ifkill_after_timeoutisnotNone:
991996
raiseGitCommandError(
992997
redacted_command,
993998
'"kill_after_timeout" feature is not supported on Windows.',
994999
)
995-
# Only search PATH, not CWD. This must be in the *caller* environment. The "1" can be any value.
996-
maybe_patch_caller_env=patch_env("NoDefaultCurrentDirectoryInExePath","1")
997-
else:
998-
cmd_not_found_exception=FileNotFoundError
999-
maybe_patch_caller_env=contextlib.nullcontext()
1000+
1001+
cmd_not_found_exception=OSError
1002+
1003+
# Search PATH, but do not search CWD. The "1" can be any value.
1004+
ifshell:
1005+
# If the direct subprocess is a shell, this must go in its environment.
1006+
env["NoDefaultCurrentDirectoryInExePath"]="1"
1007+
else:
1008+
# If we're not using a shell, the variable goes in our own environment.
1009+
maybe_patch_caller_env=patch_env("NoDefaultCurrentDirectoryInExePath","1")
10001010
# END handle
10011011

10021012
stdout_sink=PIPEifwith_stdoutelsegetattr(subprocess,"DEVNULL",None)oropen(os.devnull,"wb")
1003-
ifshellisNone:
1004-
shell=self.USE_SHELL
10051013
log.debug(
10061014
"Popen(%s, cwd=%s, stdin=%s, shell=%s, universal_newlines=%s)",
10071015
redacted_command,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp