xmake icon indicating copy to clipboard operation
xmake copied to clipboard

The return value of os.shell() is not reliable

Open Willaaaaaaa opened this issue 4 months ago • 1 comments

Xmake Version

3.0.3

Operating System Version and Architecture

Windows 11 24H2

Describe Bug

When you use powershell by cmd -> vscode -> powershell, os.shell() will tell you it's cmd. During this process, the environment variable PROMPT will be inherited, causing a wrong result from environment variable detection. Directly opening a powershell works as expected. https://github.com/xmake-io/xmake/blob/2fe0526ccda961b178f8e46dc179edc387c3c95e/xmake/core/base/tty.lua#L161-L164


Opening a powershell terminal after opening vscode via cmd:

PS D:\Dev\auto-blue> xmake l
xmake> os.shell()
< "cmd"

Or, you can reproduce it by opening a cmd:

C:\Users\Willaaaaaaa>powershell
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

Install the latest PowerShell for new features and improvements! https://aka.ms/PSWindows

PS C:\Users\Willaaaaaaa> xmake l
xmake> os.shell()
< "cmd"

Expected Behavior

PS C:\Users\Willaaaaaaa> xmake l
xmake> os.shell()
< "powershell"

Project Configuration

None

Additional Information and Error Logs

None

Willaaaaaaa avatar Oct 15 '25 06:10 Willaaaaaaa

There is no reliable way to detect it right now, if you know it, you can directly improve it.

waruqi avatar Oct 15 '25 07:10 waruqi