From c538d70823331159f1b382b81496884bc5a02fb1 Mon Sep 17 00:00:00 2001 From: Venelin Date: Wed, 11 Dec 2024 01:16:55 +0200 Subject: [PATCH] print command --- install.sh | 2 +- src/commands.hpp | 3 +++ src/commands.inl | 7 +++++++ todo.txt | 2 ++ 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 5b3639a..2c6b19c 100755 --- a/install.sh +++ b/install.sh @@ -14,8 +14,8 @@ mv cppipe ${PREFIX}/bin # Install headers mkdir -p ${PREFIX}/include/cppipe -cp basicTypes.h commands.hpp commands.inl childProcess.hpp childProcess.inl ${PREFIX}/include/cppipe chmod 755 ${PREFIX}/include/cppipe +cp basicTypes.h commands.hpp commands.inl childProcess.hpp childProcess.inl ${PREFIX}/include/cppipe chmod 644 ${PREFIX}/include/cppipe/* # Clear old cache diff --git a/src/commands.hpp b/src/commands.hpp index f5c69de..3b893fb 100644 --- a/src/commands.hpp +++ b/src/commands.hpp @@ -161,4 +161,7 @@ PendingCmd operator&(const PendingCmd&, const Cmd&); */ std::string $(const PendingCmd&); +/* Operator<< for printing */ +std::ostream& operator<<(std::ostream&, const Cmd&); + #include "commands.inl" diff --git a/src/commands.inl b/src/commands.inl index 3eed232..298b56f 100644 --- a/src/commands.inl +++ b/src/commands.inl @@ -283,3 +283,10 @@ inline PendingCmd operator&(const PendingCmd& cleft, const Cmd& right) const_cast(cleft).detach(); return PendingCmd(right); } + +inline std::ostream& operator<<(std::ostream& s, const Cmd& c) +{ + for(size_t i = 0; i < c.argv.size() - 1; ++i) + s << '"' << c.argv[i] << '"' << ' '; + return s << std::endl; +} diff --git a/todo.txt b/todo.txt index 6d9f298..8b81443 100644 --- a/todo.txt +++ b/todo.txt @@ -5,6 +5,8 @@ cppipe compile options from tft respect CXXFLAGS LDFLAGS ? +run(cmd) +string args args before src file go to compiler use exceptions (open_or_die) precompiled header cppipe.h