Skip to content

Commit

Permalink
fix: always detect the host shell on MacOS
Browse files Browse the repository at this point in the history
Signed-off-by: Frost Ming <me@frostming.com>
  • Loading branch information
frostming committed Oct 24, 2023
1 parent e5bdc07 commit 319c7f2
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 10 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ on:

jobs:
lint:
runs-on: ubuntu-latest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
- run: pip install black ruff
- run: |
- run: |
ruff check src
black --check src
build:
Expand All @@ -20,13 +20,13 @@ jobs:
strategy:
matrix:
platform: [ubuntu-latest, macos-latest, windows-latest]
python-version: [3.7, 3.8, 3.9, '3.10', '3.11']
python-version: [3.7, 3.8, 3.9, '3.10', '3.11', '3.12']

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Install build dependencies
run: python -m pip install --upgrade build
Expand Down
1 change: 1 addition & 0 deletions news/81.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix a bug that ``detect_shell()`` always returns the host shell on MacOS.
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ classifier =
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Programming Language :: Python :: 3.12
Topic :: Software Development :: Libraries :: Python Modules

[options]
Expand Down
4 changes: 2 additions & 2 deletions src/shellingham/posix/ps.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def iter_process_parents(pid, max_depth=10):
processes_mapping = {}
for line in output.split("\n"):
try:
pid, ppid, args = line.strip().split(None, 2)
_pid, ppid, args = line.strip().split(None, 2)
# XXX: This is not right, but we are really out of options.
# ps does not offer a sane way to decode the argument display,
# and this is "Good Enough" for obtaining shell names. Hopefully
Expand All @@ -40,7 +40,7 @@ def iter_process_parents(pid, max_depth=10):
args = tuple(a.strip() for a in args.split(" "))
except ValueError:
continue
processes_mapping[pid] = Process(args=args, pid=pid, ppid=ppid)
processes_mapping[_pid] = Process(args=args, pid=_pid, ppid=ppid)

for _ in range(max_depth):
try:
Expand Down

0 comments on commit 319c7f2

Please sign in to comment.