osgi - gogoshell own commands piping -


i'm trying use gogo-shell add console commands example i'm create commands add , show

public void add(commandsession commandsession, int i) {     list<integer> il = commandsession.get("list");     if (il == null) {         il = new arraylist<integer>();         il.add(i);         commandsession.put("list",il)     } else {         il.add(i)     } } public void show(commandsession commandsession) {     list<integer> il = commandsession.get("list");     il.foreach(system.out::println); } 

and when use them like

add 1 | add 2 | add 3 | add 4 | show 

i'm geting like

null pointer exception 

or

1 3 4 2 

i think happens because pipes (add) runs in parallel. how can write command piping sequential.

pipelines in gogo (like in bash) expect consume data standard input , produce data on standard output. each element in pipeline runs concurrently, separate thread.

the 'add' command in example not consume or produce data on standard in/out , not suitable run in pipeline.

if want commands run sequentially, use ';' command separator:

g! add 1; add 2; add 3; add 4; show


Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -