[ 
https://issues.apache.org/jira/browse/FELIX-1474?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12749837#action_12749837
 ] 

Derek Baum commented on FELIX-1474:
-----------------------------------

I was thinking of a simpler approach, that doesn't introduce new syntax:

Currently, Pipe.run() does this:

            for (List<CharSequence> statement : statements)
            {
                result = closure.executeStatement(statement);
                if (result != null && pout != null)
                {
                    out.println(closure.session.format(result, 
Converter.INSPECT));
                }
            }

I was thinking of adding a session variable to control this behaviour, e.g.

pipeformat = inspect

if the variable is not set, then default to the current behaviour.
if the value of pipeformat is a valid Converter format (i.e. inspect | line | 
part), then print the result to the pipe using this format;
otherwise don't print the result to the pipe.

So, setting pipeformat=none would stop results being automatically written to 
the pipe.





> [gogo] result of commands is implicitly written to pipe
> -------------------------------------------------------
>
>                 Key: FELIX-1474
>                 URL: https://issues.apache.org/jira/browse/FELIX-1474
>             Project: Felix
>          Issue Type: Bug
>          Components: Gogo
>            Reporter: Derek Baum
>            Priority: Minor
>
> RFC132 commands are designed to be easy to create, allowing direct use of 
> System.out
> void echo1(String[] args) {
>     StrinbgBuilder buf = new StringBuilder();
>     for (String arg : args) {
>         if (buf.length() > 0)
>             buf.append(' ');
>         buf.append(arg)
>     }
>     System.out.println(buf.toString());
> }
> but it also allows commands that return values:
> String echo2(String[] args) {
>     StrinbgBuilder buf = new StringBuilder();
>     for (String arg : args) {
>         if (buf.length() > 0)
>             buf.append(' ');
>         buf.append(arg)
>     }
>     return(buf.toString());
> }
> Both these command cause grep to match 'hello':
> % echo1 hello | grep hello
> % echo2 hello | grep hello
> This is expected with echo1, as it writes to System.out.
> It is more surprising that echo2 also works, as it doesn't write to 
> System.out.
> In this case, the runtime is implicitly writing the result of 'echo2 hello' 
> into the pipe.
> This is convenient, as it lets commands that don't write to System.out be 
> used in pipelines.
> However, it can also get in the way.
> I have a grep command that writes to System.out and returns a boolean, 
> depending on whether it matched:
> % bundles | grep felix | wc
> but in this case, the wc command gets the output from grep and also the 
> result of grep (true)  which not wanted,
> so I would like some way of disabling this behaviour.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to