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