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

feat: make query_command shell-agnostic #19

Merged
merged 10 commits into from
Oct 9, 2024

Conversation

bugabinga
Copy link
Contributor

@bugabinga bugabinga commented Feb 27, 2024

fixes #18
query_command is now of type table so that vim.fn.jobstart does
not use shell.

Tested on Windows 11 with nushell.
Needs testing in:

  • linux
  • linux + sudo
  • macos
  • WSL

The code in parse_query_response now needs to handle a table, instead of a string, because the query_command cannot use pipes any more, which previously guaranteed that stdout consisted of one line.

`query_command` is now of type `table` so that `vim.fn.jobstart` does
not use `shell`.
@bugabinga bugabinga changed the title fix #18 by making query_command shell-agnostic making query_command shell-agnostic Feb 27, 2024
@nekowinston nekowinston self-assigned this Feb 27, 2024
@nekowinston nekowinston self-requested a review February 27, 2024 18:36
else
return
end

if vim.fn.has("unix") ~= 0 then
if vim.loop.getuid() == 0 then
query_command = "su - $SUDO_USER -c " .. query_command
query_command = vim.tbl_extend("keep", { "su", "-", "$SUDO_USER", "-c" }, query_command)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm unsure how this command will behave now.
It seems like su will spawn the default shell indicated in /etc/passwd?

Copy link
Collaborator

@nekowinston nekowinston left a comment

Choose a reason for hiding this comment

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

This PR so far (with my suggestions applied) breaks the plugin on Linux/NixOS for me.

I'll take another look on Linux and macOS tomorrow.

lua/auto-dark-mode/init.lua Outdated Show resolved Hide resolved
@f-person
Copy link
Owner

Hey @nekowinston! Does your commit fix the issues with the PR? Feel free to merge this if it works for you or close it otherwise :)

@nekowinston
Copy link
Collaborator

nekowinston commented Apr 13, 2024

It doesn't, my commit so far was a simple syntax error fix, the whole PR doesn't work for me in its current state.
I meant to get back to this, but I currently don't have much time for FOSS work... 😓

@f-person
Copy link
Owner

No worries, do as you wish whenever you wish with this one :)

@bugabinga
Copy link
Contributor Author

I have tested this branch on Windows, WSL and Fedora 40 and those work.
Unfortunately, I have no NixOs system to test on.

this should help with escalation methods that aren't sudo, we don't have
to add support for them right now, but at least alert the user that an
error occurred.
@nekowinston
Copy link
Collaborator

nekowinston commented Oct 9, 2024

Sorry for taking ages to get to this! 😓
Going to try this on my other machines; will merge it should everything work well.

As an aside, I've also started to use nushell exclusively on my system, so this PR is much appreciated.

@nekowinston nekowinston changed the title making query_command shell-agnostic feat: make query_command shell-agnostic Oct 9, 2024
Copy link
Collaborator

@nekowinston nekowinston left a comment

Choose a reason for hiding this comment

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

Successfully tested on:

  • Linux/NixOS
  • macOS Sequoia
  • Windows 10
  • WSL

and again, thanks for your contribution 😄

@nekowinston nekowinston merged commit d365bec into f-person:master Oct 9, 2024
1 check passed
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.

Unreliable with non-standard shell
3 participants