adoroszlai opened a new pull request, #12005:
URL: https://github.com/apache/ozone/pull/12005

   ## What changes were proposed in this pull request?
   
   JLine supports [output 
redirection](https://jline.org/versions/3.x/docs/modules/repl-console#pipes-and-output-redirection)
 (`>` and `>>` operators), but `getOut` and `getErr` from `CommandLine` do not 
work well with it.  They keep writing to their initial streams, which may be 
screen or some file, depending on the first command.
   
   ```bash
   $ ozone freon ockg -n1 -t1 -p test
   ...
   
   $ ozone sh --interactive
   ozone sh> key list /vol1/bucket1
   [ {
       ...
   } ]
   
   # should be redirected
   ozone sh> key list /vol1/bucket1 > /tmp/key-list
   [ {
       ...
   } ]
   
   ozone sh> ^D
   
   # file is empty
   $ wc -l /tmp/key-list
   0 /tmp/key-list
   
   $ ozone sh --interactive
   ozone sh> key list /vol1/bucket1 > /tmp/key-list2
   
   # should not be redirected
   ozone sh> key list /vol1/bucket1 
   
   ozone sh> ^D
   
   # file contains output from both commands
   $ wc -l /tmp/key-list2
   70 /tmp/key-list2
   
   $ 
   ```
   
   This PR fixes the problem by replace usage of `getOut()` and `getErr()` with 
`System.out` and `System.err`.
   
   https://issues.apache.org/jira/browse/HDDS-17760
   
   ## How was this patch tested?
   
   ```
   $ ozone sh --interactive
   ozone sh> key list /vol1/bucket1
   [ {
     ...
   } ]
   
   ozone sh> key list /vol1/bucket1 > /tmp/key-list
   
   ozone sh> ^D
   
   $ wc -l /tmp/key-list
   35 /tmp/key-list
   ```
   
   https://github.com/adoroszlai/ozone/actions/runs/42801384943
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to