Code Monkey home page Code Monkey logo

Comments (7)

uranusjr avatar uranusjr commented on June 16, 2024

How can I set up a reproduction to investigate this?

from shellingham.

ids1024 avatar ids1024 commented on June 16, 2024

I've opened a PR (#36) with a Github actions workflow testing this. Which is failing on macOS but passing on Linux.

Edit: https://github.com/ids1024/shellingham/actions/runs/280891996

from shellingham.

ids1024 avatar ids1024 commented on June 16, 2024

Or, or I guess on Linux, ps not run in a terminal lists all processes that aren't in a terminal, so this is failing for me as well, since I don't have any shells that aren't connected to a tty:

import os
import fcntl
import termios
import subprocess
import shellingham

fd = os.open("/dev/tty", os.O_RDWR | os.O_NOCTTY)
fcntl.ioctl(fd, termios.TIOCNOTTY, '')
os.close(fd)

subprocess.call(["ps"])
print(shellingham.detect_shell())
Traceback (most recent call last):
  File "test.py", line 12, in <module>
    print(shellingham.detect_shell())
  File "/home/ian/src/shellingham/shellingham/__init__.py", line 25, in detect_shell
    raise ShellDetectionFailure()
shellingham._core.ShellDetectionFailure

from shellingham.

uranusjr avatar uranusjr commented on June 16, 2024

on Linux, ps not run in a terminal lists all processes that aren't in a terminal

Hmm. I wonder why that’d work on GitHub Actions though? Shellingham tests the shell is in the current process’s parent chain, so maybe it’s detecting the login shell in this case? If so, this arguably be attributed to a Linux quirk and unfixable in shellingham.

from shellingham.

uranusjr avatar uranusjr commented on June 16, 2024

Nope, there is legistimately a shell detected, persuambly the one used to run the commands you specify in run. But why does not the macOS worker have the same thing? I guess GitHub Actions is just implemented differently for different platforms, and there’s no real solution here.

from shellingham.

ids1024 avatar ids1024 commented on June 16, 2024

It's a pain to debug with actually having a Mac to try things on locally, but it seemed when I just ran ps on a macOS GitHub action runner, it produced no output. So it seems the behavior of ps on macOS is different when there's not a connected tty.

Using something like ps -e to list all processes would probably fix it. If that's portable. Glancing at the ps(1) man page on Linux, it seems there's a fair bit of variation between different implementations and standards.

from shellingham.

JeppeKlitgaard avatar JeppeKlitgaard commented on June 16, 2024

For whatever reason this is fixed by #49

Edit: I just realised this is because #49 changes the GitHub actions to instead run the tests using pytest.

from shellingham.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.