Skip to content

Commit 2ca3559

Browse files
fix: update subprocess shell handling for cross-platform compatibility
1 parent 3ce0b25 commit 2ca3559

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

scripts/post_deploy.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,12 @@
3838
import base64
3939
import json
4040
import os
41-
import platform
4241
import subprocess
4342
import sys
4443
from dataclasses import dataclass
4544
from pathlib import Path
4645
from typing import Dict, Optional
4746

48-
# shell=True is required on Windows so the shell can resolve az.cmd/az.ps1;
49-
# on Linux/macOS az is a real executable so shell=True must NOT be used with
50-
# a list argument (it would cause only the first token to be executed).
51-
_SHELL = platform.system() == "Windows"
52-
5347
try:
5448
import httpx
5549
except ModuleNotFoundError as exc:
@@ -122,7 +116,7 @@ def get_values_from_az_deployment(resource_group: str) -> Optional[Dict[str, str
122116
capture_output=True,
123117
text=True,
124118
check=True,
125-
shell=_SHELL
119+
shell=(os.name == "nt") # Required on Windows to find az.cmd
126120
)
127121
deployment_name = result.stdout.strip()
128122

@@ -139,7 +133,7 @@ def get_values_from_az_deployment(resource_group: str) -> Optional[Dict[str, str
139133
capture_output=True,
140134
text=True,
141135
check=True,
142-
shell=_SHELL
136+
shell=(os.name == "nt") # Required on Windows to find az.cmd
143137
)
144138
deployment_name = result.stdout.strip()
145139

@@ -162,7 +156,7 @@ def get_values_from_az_deployment(resource_group: str) -> Optional[Dict[str, str
162156
capture_output=True,
163157
text=True,
164158
check=True,
165-
shell=_SHELL
159+
shell=(os.name == "nt") # Required on Windows to find az.cmd
166160
)
167161

168162
outputs = json.loads(result.stdout)

0 commit comments

Comments
 (0)