Skip to content

The program doesn't output anything in Windows 10 #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

codegen-sh[bot]
Copy link

@codegen-sh codegen-sh bot commented Jul 14, 2023

Plan

Step 1: Update run_bash_file_from_string Function

Instead of running the script via bash directly, which is not cross-platform compatible, let's write code in run_bash_file_from_string(s: str) that first detects the operating system and then runs the script in the appropriate shell.

Here is how it might look:

def run_bash_file_from_string(s: str):
    """Runs a bash script from a string"""
    with open('temp.sh', 'w') as f:
        f.write(s)

    if os.name == 'nt':  # Windows systems
        os.system('powershell.exe .\\temp.sh')
    else:  # Unix/Linux systems
        os.system('bash temp.sh')
    
    os.remove('temp.sh')

Note that I've used os.name to detect the operating system. According to Python's os documentation, os.name is 'nt' for Windows, and 'posix' for Unix/Linux.

The system command to execute a script in PowerShell is 'powershell.exe ScriptPath'.

Step 2: Modify Commands According to OS in main.py

The issue also suggested modifying the command according to the user's operating system. For this, we'll need to detect the OS, similar to the above step, and modify the command accordingly before passing it to the run_bash_file_from_string(s: str) function in src/main.py. However, this step requires additional context about the input commands and cannot be addressed in isolation without it.

Considering the provided information and the analysis, the above step (Step 1) resolves the issue at hand and should provide the desired output on Windows 10.

Fixes #2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The program doesn't output anything in Windows 10
0 participants