Skip to content

Commit 7ea2d7c

Browse files
authored
Merge pull request #206 from Frostday/main
Fix for issue #134
2 parents 1f4de91 + 59cd1c2 commit 7ea2d7c

File tree

8 files changed

+602
-28
lines changed

8 files changed

+602
-28
lines changed

.pdd/meta/admin_get_users_python_run.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"timestamp": "2025-12-15T23:18:07.519096+00:00",
2+
"timestamp": "2025-12-20T02:05:12.779846+00:00",
33
"exit_code": 0,
44
"tests_passed": 1,
55
"tests_failed": 0,

.pdd/meta/my_module_python_run.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"timestamp": "2025-12-15T23:18:07.516976+00:00",
2+
"timestamp": "2025-12-20T02:05:12.777629+00:00",
33
"exit_code": 0,
44
"tests_passed": 1,
55
"tests_failed": 0,

.pdd/meta/simple_math_python.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"pdd_version": "0.0.84",
3-
"timestamp": "2025-12-15T23:18:14.786118+00:00",
2+
"pdd_version": "0.0.87",
3+
"timestamp": "2025-12-20T02:05:18.076987+00:00",
44
"command": "test",
55
"prompt_hash": "d4357fbb6b142ab7feb3a75a575e46dae19c83cf493765bda3922bd98a3a7ea5",
66
"code_hash": null,
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
2-
"timestamp": "2025-12-15T23:18:14.409837+00:00",
3-
"exit_code": 0,
4-
"tests_passed": 2,
5-
"tests_failed": 0,
6-
"coverage": 100.0,
2+
"timestamp": "2025-12-20T02:05:17.514948+00:00",
3+
"exit_code": 2,
4+
"tests_passed": 0,
5+
"tests_failed": 1,
6+
"coverage": 0.0,
77
"test_hash": "cb09a5c55340648bf4da079f83efa25b815ec557b01971793c35336b0b925be4"
88
}

.pdd/meta/test_broken_fixture_python_run.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"timestamp": "2025-12-15T23:18:06.698878+00:00",
2+
"timestamp": "2025-12-20T02:05:11.783112+00:00",
33
"exit_code": 1,
44
"tests_passed": 1,
55
"tests_failed": 1,

.pdd/meta/test_mixed_python_run.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"timestamp": "2025-12-15T23:18:07.108222+00:00",
2+
"timestamp": "2025-12-20T02:05:12.273198+00:00",
33
"exit_code": 1,
44
"tests_passed": 1,
55
"tests_failed": 2,

pdd/setup_tool.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import requests
1212
import csv
1313
import importlib.resources
14+
import shlex
1415
from pathlib import Path
1516
from typing import Dict, Optional, Tuple, List
1617

@@ -309,24 +310,23 @@ def get_shell_init_file(shell: str) -> str:
309310
return str(shell_files.get(shell, home / '.bashrc'))
310311

311312
def create_api_env_script(keys: Dict[str, str], shell: str) -> str:
312-
"""Create shell-appropriate environment script"""
313+
"""Create shell-appropriate environment script with proper escaping"""
313314
valid_keys = {k: v for k, v in keys.items() if v}
315+
lines = []
314316

315-
if shell == 'fish':
316-
lines = []
317-
for key, value in valid_keys.items():
318-
lines.append(f'set -gx {key} "{value}"')
319-
return '\n'.join(lines) + '\n'
320-
elif shell in ['csh', 'tcsh']:
321-
lines = []
322-
for key, value in valid_keys.items():
323-
lines.append(f'setenv {key} "{value}"')
324-
return '\n'.join(lines) + '\n'
325-
else: # bash, zsh, ksh, sh and others
326-
lines = []
327-
for key, value in valid_keys.items():
328-
lines.append(f'export {key}="{value}"')
329-
return '\n'.join(lines) + '\n'
317+
for key, value in valid_keys.items():
318+
# shlex.quote is designed for POSIX shells (sh, bash, zsh, ksh)
319+
# It also works reasonably well for fish and csh for simple assignments
320+
quoted_val = shlex.quote(value)
321+
322+
if shell == 'fish':
323+
lines.append(f'set -gx {key} {quoted_val}')
324+
elif shell in ['csh', 'tcsh']:
325+
lines.append(f'setenv {key} {quoted_val}')
326+
else: # bash, zsh, ksh, sh and others
327+
lines.append(f'export {key}={quoted_val}')
328+
329+
return '\n'.join(lines) + '\n'
330330

331331
def save_configuration(valid_keys: Dict[str, str]) -> Tuple[List[str], bool, Optional[str]]:
332332
"""Save configuration to ~/.pdd/ directory"""
@@ -645,4 +645,4 @@ def main():
645645
main()
646646
except KeyboardInterrupt:
647647
print_colored("\n\nSetup cancelled.", YELLOW)
648-
sys.exit(0)
648+
sys.exit(0)

0 commit comments

Comments
 (0)