2024-03-15 00:44:43 +00:00
|
|
|
#pragma once
|
2024-04-08 22:07:57 +00:00
|
|
|
///@file
|
2024-03-15 00:44:43 +00:00
|
|
|
|
|
|
|
#include <regex>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "error.hh"
|
|
|
|
|
|
|
|
namespace nix {
|
|
|
|
|
|
|
|
class ShlexError : public Error
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
const std::string input;
|
|
|
|
|
|
|
|
ShlexError(const std::string input)
|
|
|
|
: Error("Failed to parse shell arguments (unterminated quote?): %1%", input)
|
|
|
|
, input(input)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Parse a string into shell arguments.
|
|
|
|
*
|
|
|
|
* Takes care of whitespace, quotes, and backslashes (at least a bit).
|
|
|
|
*/
|
|
|
|
std::vector<std::string> shell_split(const std::string & input);
|
|
|
|
|
|
|
|
} // namespace nix
|