You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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 therun
function exported byuebersicht
. Both of these approaches to running commands are handled bycommand_server.coffee
, which spawns abash
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"];
andrun(["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.The text was updated successfully, but these errors were encountered: