Skip to content
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

Executable files without an extension attempt to open without use of xdg-open, resulting in traceback #124

Open
themooleman opened this issue Jun 12, 2022 · 0 comments

Comments

@themooleman
Copy link

themooleman commented Jun 12, 2022

If a file without an extension contains an execute bit, opening the file with the default text editor fails with traceback (see below). Here, I am attempting to open the file "foo" (octal 744) by providing the path and pressing enter:

Traceback (most recent call last): File "/usr/bin/dmenu_extended_run", line 7, in <module> dmenu_extended.run(*sys.argv) File "/usr/lib/python3.10/site-packages/dmenu_extended/main.py", line 2015, in run handle_command(d, out) File "/usr/lib/python3.10/site-packages/dmenu_extended/main.py", line 1593, in handle_command d.execute(out) File "/usr/lib/python3.10/site-packages/dmenu_extended/main.py", line 717, in execute return subprocess.call(command) File "/usr/lib/python3.10/subprocess.py", line 345, in call with Popen(*popenargs, **kwargs) as p: File "/usr/lib/python3.10/subprocess.py", line 969, in __init__ self._execute_child(args, executable, preexec_fn, close_fds, File "/usr/lib/python3.10/subprocess.py", line 1845, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) OSError: [Errno 8] Exec format error: '/home/theo/foo'

If, however, the execute bit is removed (chmod 644), the file opens as expected in the default text editor (in my case terminal vim).

Note that if the file has an extension, e.g. foo.txt, it will open correctly, even if executable.

Reviewing the traceback, it would seem that if the file is executable and lacks an extension, dmenu_extended_run attempts to open it without using xdg-open. If the file has an extension and/or is not executable, it attempts to open it using xdg-open and thus succeeds.

@themooleman themooleman changed the title Executable files without an extension fail with traceback Executable files without an extension attempt to open without use of xdg-open, resulting in traceback Jun 12, 2022
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

No branches or pull requests

1 participant