diff options
Diffstat (limited to 'src/libutil/util.hh')
-rw-r--r-- | src/libutil/util.hh | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/libutil/util.hh b/src/libutil/util.hh index c5c537ee63d8..743d238611fc 100644 --- a/src/libutil/util.hh +++ b/src/libutil/util.hh @@ -25,6 +25,9 @@ namespace nix { +struct Sink; +struct Source; + /* Return an environment variable. */ string getEnv(const string & key, const string & def = ""); @@ -148,8 +151,9 @@ MakeError(EndOfFile, Error) /* Read a file descriptor until EOF occurs. */ -string drainFD(int fd); +string drainFD(int fd, bool block = true); +void drainFD(int fd, Sink & sink, bool block = true); /* Automatic cleanup of resources. */ @@ -256,6 +260,8 @@ struct RunOptions bool searchPath = true; Strings args; std::experimental::optional<std::string> input; + Source * standardIn = nullptr; + Sink * standardOut = nullptr; bool _killStderr = false; RunOptions(const Path & program, const Strings & args) @@ -266,6 +272,8 @@ struct RunOptions std::pair<int, std::string> runProgram(const RunOptions & options); +void runProgram2(const RunOptions & options); + class ExecError : public Error { @@ -391,11 +399,13 @@ void ignoreException(); #define ANSI_BLUE "\e[34;1m" -/* Truncate a string to 'width' printable characters. Certain ANSI - escape sequences (such as colour setting) are copied but not - included in the character count. Other ANSI escape sequences are - filtered. Also, tabs are expanded to spaces. */ +/* Truncate a string to 'width' printable characters. If 'filterAll' + is true, all ANSI escape sequences are filtered out. Otherwise, + some escape sequences (such as colour setting) are copied but not + included in the character count. Also, tabs are expanded to + spaces. */ std::string filterANSIEscapes(const std::string & s, + bool filterAll = false, unsigned int width = std::numeric_limits<unsigned int>::max()); |