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

Avoid hardcoded xdg-open path and resolve incoming paths #1531

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

fidgetingbits
Copy link
Collaborator

This fixes using xdg-open while on nixos and also resolves paths passed in, so if someone uses ~/ or similar in their path it'll work.

@@ -67,7 +71,11 @@ def edit_text_file(path):
# we use xdg-open for this even though it might not open a text
# editor. we could use $EDITOR, but that might be something that
# requires a terminal (eg nano, vi).
open_with_subprocess(path, ["/usr/bin/xdg-open", path])
open_cmd = shutil.which("xdg-open")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had raised that this would be a problem on NixOS back in the original PR too: #847 (comment)

Time to start this discussion again I guess. cc @rntz

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we are concerned about malicious binaries injected into PATH folders enough to avoid calling which, then I can change it to test a set of hardcoded paths to try find it and include /run/current-system/sw/bin/ for nixos, though I'm not sure that will always work for all possible setups. Could cache the path after the first go to not have to search through a list each time too.

There is a which call in PR #1471, to fix a similar issue on nixos, that will need to change depending on what gets decided.

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

Successfully merging this pull request may close these issues.

2 participants