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

Plugin API: terminal_command strips away quotes #3880

Open
msirringhaus opened this issue Dec 17, 2024 · 0 comments
Open

Plugin API: terminal_command strips away quotes #3880

msirringhaus opened this issue Dec 17, 2024 · 0 comments

Comments

@msirringhaus
Copy link
Contributor

Issue description

The PaneInfo that a plugin receives on PaneUpdate-events contains the terminal_command as a string. This string is however missing the quotes that the command was launched with, e.g.:
bash -ic ssh server instead of the expected bash -ic "ssh server".

Thus, splitting the command into it's bash-components doesn't work (["bash", "-ic", "ssh", "server"] vs. expected: ["bash", "-ic", "ssh server"]).

Minimal reproduction

use zellij_tile::prelude::*;

use std::collections::BTreeMap;

#[derive(Default)]
struct State {
    manifest: PaneManifest,
}

register_plugin!(State);

impl ZellijPlugin for State {
    fn load(&mut self, _configuration: BTreeMap<String, String>) {
        request_permission(&[PermissionType::ReadApplicationState]);
        subscribe(&[EventType::PaneUpdate]);
    }
    fn update(&mut self, event: Event) -> bool {
        match event {
            Event::PaneUpdate(manifest) => {
                self.manifest = manifest;
                true
            }
            _ => false,
        }
    }
    fn render(&mut self, _rows: usize, _cols: usize) {
        println!("The command panes:");
        for panes in self.manifest.panes.values() {
            for pane in panes {
                if !pane.is_plugin {
                    println!("{:?}", &pane.terminal_command);
                }
            }
        }
    }
}

Open this plugin with zellij plugin --skip-plugin-cache -- file:/path/to/rust-plugin-example/target/wasm32-wasi/debug/rust-plugin-example.wasm , then open a command pane with zr ssh server or zellij run -- bash -ic "ssh server" and look at the output.

The output should contain Some("bash -ic \"ssh server\""), but has Some("bash -ic ssh server").

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