From abec2980ef1ff051be14c26097a76b6429b3b7bc Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 8 Jan 2016 00:35:39 +0100 Subject: support '-' and no parameter for stdin in apt-helper cat-file This way it works more similar to the compressor binaries, which we can relief in this way from their job in the test framework avoiding the need of adding e.g. liblz4-tool to the test dependencies. --- cmdline/apt-helper.cc | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'cmdline') diff --git a/cmdline/apt-helper.cc b/cmdline/apt-helper.cc index 001b5e5f7..b92055ab7 100644 --- a/cmdline/apt-helper.cc +++ b/cmdline/apt-helper.cc @@ -145,14 +145,28 @@ static bool DoCatFile(CommandLine &CmdL) /*{{{*/ } if (CmdL.FileSize() <= 1) - return _error->Error("Must specify at least one file name"); + { + if (fd.OpenDescriptor(STDIN_FILENO, FileFd::ReadOnly) == false) + return false; + if (CopyFile(fd, out) == false) + return false; + return true; + } for(size_t i = 1; CmdL.FileList[i] != NULL; ++i) { std::string const name = CmdL.FileList[i]; - if (fd.Open(name, FileFd::ReadOnly, FileFd::Extension) == false) - return false; + if (name != "-") + { + if (fd.Open(name, FileFd::ReadOnly, FileFd::Extension) == false) + return false; + } + else + { + if (fd.OpenDescriptor(STDIN_FILENO, FileFd::ReadOnly) == false) + return false; + } if (CopyFile(fd, out) == false) return false; -- cgit v1.2.3