diff --git a/src/libutil/include/nix/util/table.hh b/src/libutil/include/nix/util/table.hh index c42cc1d8f..13e4506d5 100644 --- a/src/libutil/include/nix/util/table.hh +++ b/src/libutil/include/nix/util/table.hh @@ -6,6 +6,6 @@ namespace nix { typedef std::vector> Table; -void printTable(Table & table); +void printTable(std::ostream & out, Table & table); } // namespace nix diff --git a/src/libutil/table.cc b/src/libutil/table.cc index a64c37315..fa1bf110d 100644 --- a/src/libutil/table.cc +++ b/src/libutil/table.cc @@ -7,7 +7,7 @@ namespace nix { -void printTable(Table & table) +void printTable(std::ostream & out, Table & table) { auto nrColumns = table.size() > 0 ? table.front().size() : 0; @@ -27,11 +27,11 @@ void printTable(Table & table) for (auto j = i.begin(); j != i.end(); ++j, ++column) { std::string s = *j; replace(s.begin(), s.end(), '\n', ' '); - std::cout << s; + out << s; if (column < nrColumns - 1) - std::cout << std::string(widths[column] - s.size() + 2, ' '); + out << std::string(widths[column] - s.size() + 2, ' '); } - std::cout << std::endl; + out << std::endl; } } diff --git a/src/nix/nix-env/nix-env.cc b/src/nix/nix-env/nix-env.cc index aa5fa23c4..1c09c1e45 100644 --- a/src/nix/nix-env/nix-env.cc +++ b/src/nix/nix-env/nix-env.cc @@ -1250,7 +1250,7 @@ static void opQuery(Globals & globals, Strings opFlags, Strings opArgs) } if (!xmlOutput) - printTable(table); + printTable(std::cout, table); } static void opSwitchProfile(Globals & globals, Strings opFlags, Strings opArgs)