diff options
| author | Julian Andres Klode <julian.klode@canonical.com> | 2025-02-04 16:14:13 +0100 |
|---|---|---|
| committer | Julian Andres Klode <julian.klode@canonical.com> | 2025-02-04 16:15:17 +0100 |
| commit | ddfb32fe72ec38f27e0fa2f012c43ade421bdbd8 (patch) | |
| tree | d9c5915ffa2b74b2681459b412eee5104f372133 | |
| parent | 6ee18adb85633afc39bdca25209dcfac0ae5c3c5 (diff) | |
modernize-sources: Avoid opening /dev/stdout for simulate
/dev/stdout may not exist, so let's instead just reference
the std::cout stream.
Reported-by: h01ger on IRC
| -rw-r--r-- | apt-private/private-sources.cc | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/apt-private/private-sources.cc b/apt-private/private-sources.cc index a23955ab5..ae3af11a9 100644 --- a/apt-private/private-sources.cc +++ b/apt-private/private-sources.cc @@ -236,13 +236,12 @@ static bool Modernize(std::string const &filename) /*{{{*/ else outname = _config->FindDir("Dir::Etc::SourceParts") + (e.origin) + ".sources"; - if (auto it = streams.find(outname); it == streams.end()) + if (auto it = streams.find(outname); not simulate && it == streams.end()) { - if (not simulate) - std::cerr << "- Writing " << outname << "\n"; - streams[outname].open(simulate ? "/dev/stdout" : outname, std::ios::app); + std::cerr << "- Writing " << outname << "\n"; + streams[outname].open(outname, std::ios::app); } - auto &out = streams[outname]; + auto &out = simulate ? std::cout : streams[outname]; if (not out) _error->Warning("Cannot open %s for writing.", outname.c_str()); if (e.merged) |
