Class ExecHelper


  • public final class ExecHelper
    extends java.lang.Object
    Utility class for executing external commands and capturing their output.

    The ExecHelper class provides methods for executing external commands (primarily on Unix-like systems) and capturing their output. It handles the complexities of process creation, input/output redirection, and process termination.

    This class is used by various JLine components that need to interact with the underlying operating system, such as terminal detection, capability querying, and terminal size determination. It provides a simplified interface for executing commands and capturing their output as strings.

    The methods in this class handle common error conditions, such as interrupted execution and I/O errors, and provide appropriate logging for debugging purposes.

    Note that while this class is primarily designed for Unix-like systems, some functionality may work on other platforms depending on the available commands.

    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String exec​(boolean redirectInput, java.lang.String... cmd)  
      static java.lang.String waitAndCapture​(java.lang.Process p)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • exec

        public static java.lang.String exec​(boolean redirectInput,
                                            java.lang.String... cmd)
                                     throws java.io.IOException
        Throws:
        java.io.IOException
      • waitAndCapture

        public static java.lang.String waitAndCapture​(java.lang.Process p)
                                               throws java.io.IOException,
                                                      java.lang.InterruptedException
        Throws:
        java.io.IOException
        java.lang.InterruptedException