Elasticsearch plugin list behavior

I created a puppet defined type to handle logstash plugins install/removal automatically.

define logstash::plugin (
    $command   = install,
    $logoutput = true,
) {
    exec {
        "$name":
            command     => "/opt/logstash/bin/plugin $command $name",
            logoutput   => $logoutput,
            path        => ["/bin", "/sbin", "/usr/bin", "/usr/sbin"],
            unless      => "/opt/logstash/bin/plugin list $name",
        ;
    }
}

before attempting anything, it checks if the plugin is already installed by issuing the list command
/opt/logstash/bin/plugin list $name

i would like to do the same with elasticsearch plugins, but issuing a similar command
/usr/share/elasticsearch/bin/plugin list $name
always return all installed plugins

is there any way to get it to accept a plugin name as argument and return only that given name, like logstash plugin above?

Are you able to filter the plugin command through grep? If so something like /usr/share/elasticsearch/bin/plugin list | grep -q "- $name$" should work.

yes, this is what i'm doing right now.

i was just trying to avoid pipe ( | ) and short-circuit (&& || ) because the bin/plugin exit codes are not consistent.

for example, bin/plugin remove always exits with status 0, even if the plugin name passed as argument does not exists.

this makes it really hard to be scripted.

the way i see, it should exit with status 1 if a plugin was not removed.