|
18 | 18 |
|
19 | 19 | #include <fstream>
|
20 | 20 |
|
21 |
| -/// quote a string for bash and CMD |
22 |
| -static std::string shell_quote(const std::string &src) |
23 |
| -{ |
24 |
| - #ifdef _WIN32 |
25 |
| - // first check if quoting is needed at all |
26 |
| - |
27 |
| - if(src.find(' ')==std::string::npos && |
28 |
| - src.find('"')==std::string::npos && |
29 |
| - src.find('&')==std::string::npos && |
30 |
| - src.find('|')==std::string::npos && |
31 |
| - src.find('(')==std::string::npos && |
32 |
| - src.find(')')==std::string::npos && |
33 |
| - src.find('<')==std::string::npos && |
34 |
| - src.find('>')==std::string::npos && |
35 |
| - src.find('^')==std::string::npos) |
36 |
| - { |
37 |
| - // seems fine -- return as is |
38 |
| - return src; |
39 |
| - } |
40 |
| - |
41 |
| - std::string result; |
42 |
| - |
43 |
| - result+='"'; |
44 |
| - |
45 |
| - for(const char ch : src) |
46 |
| - { |
47 |
| - if(ch=='"') |
48 |
| - result+='"'; // quotes are doubled |
49 |
| - result+=ch; |
50 |
| - } |
51 |
| - |
52 |
| - result+='"'; |
53 |
| - |
54 |
| - return result; |
55 |
| - |
56 |
| - #else |
57 |
| - |
58 |
| - // first check if quoting is needed at all |
59 |
| - |
60 |
| - if(src.find(' ')==std::string::npos && |
61 |
| - src.find('"')==std::string::npos && |
62 |
| - src.find('*')==std::string::npos && |
63 |
| - src.find('$')==std::string::npos && |
64 |
| - src.find('\\')==std::string::npos && |
65 |
| - src.find('?')==std::string::npos && |
66 |
| - src.find('&')==std::string::npos && |
67 |
| - src.find('|')==std::string::npos && |
68 |
| - src.find('>')==std::string::npos && |
69 |
| - src.find('<')==std::string::npos && |
70 |
| - src.find('^')==std::string::npos && |
71 |
| - src.find('\'')==std::string::npos) |
72 |
| - { |
73 |
| - // seems fine -- return as is |
74 |
| - return src; |
75 |
| - } |
76 |
| - |
77 |
| - std::string result; |
78 |
| - |
79 |
| - // the single quotes catch everything but themselves! |
80 |
| - result+='\''; |
81 |
| - |
82 |
| - for(const char ch : src) |
83 |
| - { |
84 |
| - if(ch=='\'') |
85 |
| - result+="'\\''"; |
86 |
| - result+=ch; |
87 |
| - } |
88 |
| - |
89 |
| - result+='\''; |
90 |
| - |
91 |
| - return result; |
92 |
| - #endif |
93 |
| -} |
94 |
| - |
95 | 21 | static void error_parse_line(
|
96 | 22 | const std::string &line,
|
97 | 23 | bool warning_only,
|
|
0 commit comments