aboutsummaryrefslogtreecommitdiff
path: root/src/libutil/shlex.hh
blob: 4e7a48597df0a78689e930dc64c4dd349860e5de (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#pragma once

#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