Skip to content

Commit 3ce0b25

Browse files
fix: use platform-specific shell setting for subprocess calls in post_deploy script
1 parent 9a256c3 commit 3ce0b25

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

scripts/post_deploy.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,18 @@
3838
import base64
3939
import json
4040
import os
41+
import platform
4142
import subprocess
4243
import sys
4344
from dataclasses import dataclass
4445
from pathlib import Path
4546
from typing import Dict, Optional
4647

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+
4753
try:
4854
import httpx
4955
except ModuleNotFoundError as exc:
@@ -116,7 +122,7 @@ def get_values_from_az_deployment(resource_group: str) -> Optional[Dict[str, str
116122
capture_output=True,
117123
text=True,
118124
check=True,
119-
shell=True # Required on Windows to find az.cmd
125+
shell=_SHELL
120126
)
121127
deployment_name = result.stdout.strip()
122128

@@ -133,7 +139,7 @@ def get_values_from_az_deployment(resource_group: str) -> Optional[Dict[str, str
133139
capture_output=True,
134140
text=True,
135141
check=True,
136-
shell=True
142+
shell=_SHELL
137143
)
138144
deployment_name = result.stdout.strip()
139145

@@ -156,7 +162,7 @@ def get_values_from_az_deployment(resource_group: str) -> Optional[Dict[str, str
156162
capture_output=True,
157163
text=True,
158164
check=True,
159-
shell=True # Required on Windows to find az.cmd
165+
shell=_SHELL
160166
)
161167

162168
outputs = json.loads(result.stdout)

0 commit comments

Comments
 (0)