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

Feature request: support running commands without a shell #527

Open
00dani opened this issue Jun 20, 2024 · 1 comment
Open

Feature request: support running commands without a shell #527

00dani opened this issue Jun 20, 2024 · 1 comment

Comments

@00dani
Copy link

00dani commented Jun 20, 2024

Currently Übersicht supports defining widget behaviour as either a shell command written out as a string, or a JavaScript function that takes a dispatch function and calls it. You can also invoke shell commands from the latter by importing and calling the run function exported by uebersicht. Both of these approaches to running commands are handled by command_server.coffee, which spawns a bash process and streams the requested command into it over standard input.

What you can't currently do is spawn your desired command directly, passing its arguments as an array. This approach is slightly more efficient since it doesn't need to spawn a shell first and, more importantly, means your command won't go through Bash argument parsing and expansion before being executed, which can be helpful if your command contains spaces or other special characters. It's also easy to do this in Node - the command server already works by calling child_process.spawn("bash", args, {cwd: workingDir}), which is exactly the form it would need to use to call a pre-split command with arguments as well.

Could this be made a possibility? It wouldn't introduce a backwards compatibility break to support export const command = ["ls", "-l"]; and run(["ls", "-l"]), since neither API currently permits an array to be passed, and it'd make calling commands with a variety of options a bit cleaner. To implement this, the command server could expose an additional endpoint (say, /run/argv), which expects the array of arguments as JSON or some other structured format rather than as a plain string.

@felixhageloh
Copy link
Owner

interesting! I will keep this one in mind for the next release

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

2 participants