mirror of
https://github.com/AGWA/git-crypt.git
synced 2025-12-28 13:46:03 -08:00
Add helper to get exit status of command
This commit is contained in:
@@ -273,9 +273,9 @@ int exec_command_with_input (const std::vector<std::string>& command, const char
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool successful_exit (int status)
|
int exit_status (int wait_status)
|
||||||
{
|
{
|
||||||
return status != -1 && WIFEXITED(status) && WEXITSTATUS(status) == 0;
|
return wait_status != -1 && WIFEXITED(wait_status) ? WEXITSTATUS(wait_status) : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void touch_file (const std::string& filename)
|
void touch_file (const std::string& filename)
|
||||||
|
|||||||
@@ -316,9 +316,9 @@ int exec_command_with_input (const std::vector<std::string>& command, const char
|
|||||||
return exit_code;
|
return exit_code;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool successful_exit (int status)
|
int exit_status (int status)
|
||||||
{
|
{
|
||||||
return status == 0;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
void touch_file (const std::string& filename)
|
void touch_file (const std::string& filename)
|
||||||
|
|||||||
3
util.hpp
3
util.hpp
@@ -63,7 +63,8 @@ std::string our_exe_path ();
|
|||||||
int exec_command (const std::vector<std::string>&);
|
int exec_command (const std::vector<std::string>&);
|
||||||
int exec_command (const std::vector<std::string>&, std::ostream& output);
|
int exec_command (const std::vector<std::string>&, std::ostream& output);
|
||||||
int exec_command_with_input (const std::vector<std::string>&, const char* p, size_t len);
|
int exec_command_with_input (const std::vector<std::string>&, const char* p, size_t len);
|
||||||
bool successful_exit (int status);
|
int exit_status (int wait_status); // returns -1 if process did not exit (but was signaled, etc.)
|
||||||
|
inline bool successful_exit (int wait_status) { return exit_status(wait_status) == 0; }
|
||||||
void touch_file (const std::string&);
|
void touch_file (const std::string&);
|
||||||
void remove_file (const std::string&);
|
void remove_file (const std::string&);
|
||||||
std::string escape_shell_arg (const std::string&);
|
std::string escape_shell_arg (const std::string&);
|
||||||
|
|||||||
Reference in New Issue
Block a user