mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 00:14:41 +01:00
Get cmd.exe from a well-known location. (#5779)
Some checks are pending
Build and deploy docs / Xonsh docs to gh-pages (push) Waiting to run
CI Tests / Test Python 3.10 macOS-latest (push) Waiting to run
CI Tests / Test Python 3.11 macOS-latest (push) Waiting to run
CI Tests / Test Python 3.12 macOS-latest (push) Waiting to run
CI Tests / Test Python 3.13 macOS-latest (push) Waiting to run
CI Tests / Test Python 3.10 ubuntu-latest (push) Waiting to run
CI Tests / Test Python 3.11 ubuntu-latest (push) Waiting to run
CI Tests / Test Python 3.12 ubuntu-latest (push) Waiting to run
CI Tests / Test Python 3.13 ubuntu-latest (push) Waiting to run
CI Tests / Test Python 3.10 windows-latest (push) Waiting to run
CI Tests / Test Python 3.11 windows-latest (push) Waiting to run
CI Tests / Test Python 3.12 windows-latest (push) Waiting to run
CI Tests / Test Python 3.13 windows-latest (push) Waiting to run
Some checks are pending
Build and deploy docs / Xonsh docs to gh-pages (push) Waiting to run
CI Tests / Test Python 3.10 macOS-latest (push) Waiting to run
CI Tests / Test Python 3.11 macOS-latest (push) Waiting to run
CI Tests / Test Python 3.12 macOS-latest (push) Waiting to run
CI Tests / Test Python 3.13 macOS-latest (push) Waiting to run
CI Tests / Test Python 3.10 ubuntu-latest (push) Waiting to run
CI Tests / Test Python 3.11 ubuntu-latest (push) Waiting to run
CI Tests / Test Python 3.12 ubuntu-latest (push) Waiting to run
CI Tests / Test Python 3.13 ubuntu-latest (push) Waiting to run
CI Tests / Test Python 3.10 windows-latest (push) Waiting to run
CI Tests / Test Python 3.11 windows-latest (push) Waiting to run
CI Tests / Test Python 3.12 windows-latest (push) Waiting to run
CI Tests / Test Python 3.13 windows-latest (push) Waiting to run
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Andy Kipp <anki-code@users.noreply.github.com>
This commit is contained in:
parent
b30469fac1
commit
34b3f3cfbe
2 changed files with 36 additions and 1 deletions
23
news/5701.rst
Normal file
23
news/5701.rst
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
**Added:**
|
||||||
|
|
||||||
|
* <news item>
|
||||||
|
|
||||||
|
**Changed:**
|
||||||
|
|
||||||
|
* On Windows, cmd.exe-based aliases now resolve to %SystemRoot%\System32\cmd.exe by default (and fallback to COMSPEC only if the former cannot be found).
|
||||||
|
|
||||||
|
**Deprecated:**
|
||||||
|
|
||||||
|
* <news item>
|
||||||
|
|
||||||
|
**Removed:**
|
||||||
|
|
||||||
|
* <news item>
|
||||||
|
|
||||||
|
**Fixed:**
|
||||||
|
|
||||||
|
* <news item>
|
||||||
|
|
||||||
|
**Security:**
|
||||||
|
|
||||||
|
* <news item>
|
|
@ -5,6 +5,7 @@ import functools
|
||||||
import inspect
|
import inspect
|
||||||
import operator
|
import operator
|
||||||
import os
|
import os
|
||||||
|
import pathlib
|
||||||
import re
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
import sys
|
import sys
|
||||||
|
@ -1026,6 +1027,17 @@ def detect_xpip_alias():
|
||||||
return basecmd
|
return basecmd
|
||||||
|
|
||||||
|
|
||||||
|
def _find_cmd_exe() -> str:
|
||||||
|
"""
|
||||||
|
Resolve the cmd.exe executable.
|
||||||
|
|
||||||
|
Avoids using COMSPEC in order to allow COMSPEC to be used to
|
||||||
|
indicate Xonsh (or other shell) as the default shell. (#5701)
|
||||||
|
"""
|
||||||
|
canonical = pathlib.Path(os.environ["SystemRoot"], "System32", "cmd.exe")
|
||||||
|
return str(canonical) if canonical.is_file() else os.environ["COMSPEC"]
|
||||||
|
|
||||||
|
|
||||||
def make_default_aliases():
|
def make_default_aliases():
|
||||||
"""Creates a new default aliases dictionary."""
|
"""Creates a new default aliases dictionary."""
|
||||||
default_aliases = {
|
default_aliases = {
|
||||||
|
@ -1098,7 +1110,7 @@ def make_default_aliases():
|
||||||
"vol",
|
"vol",
|
||||||
}
|
}
|
||||||
for alias in windows_cmd_aliases:
|
for alias in windows_cmd_aliases:
|
||||||
default_aliases[alias] = [os.getenv("COMSPEC"), "/c", alias]
|
default_aliases[alias] = [_find_cmd_exe(), "/c", alias]
|
||||||
default_aliases["call"] = ["source-cmd"]
|
default_aliases["call"] = ["source-cmd"]
|
||||||
default_aliases["source-bat"] = ["source-cmd"]
|
default_aliases["source-bat"] = ["source-cmd"]
|
||||||
default_aliases["clear"] = "cls"
|
default_aliases["clear"] = "cls"
|
||||||
|
|
Loading…
Add table
Reference in a new issue