diff options
Diffstat (limited to 'xtask/src/not_bash.rs')
-rw-r--r-- | xtask/src/not_bash.rs | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/xtask/src/not_bash.rs b/xtask/src/not_bash.rs index a6431e586..0f3a56b25 100644 --- a/xtask/src/not_bash.rs +++ b/xtask/src/not_bash.rs | |||
@@ -54,7 +54,8 @@ pub mod fs2 { | |||
54 | } | 54 | } |
55 | } | 55 | } |
56 | 56 | ||
57 | macro_rules! _run { | 57 | #[macro_export] |
58 | macro_rules! run { | ||
58 | ($($expr:expr),*) => { | 59 | ($($expr:expr),*) => { |
59 | run!($($expr),*; echo = true) | 60 | run!($($expr),*; echo = true) |
60 | }; | 61 | }; |
@@ -65,7 +66,7 @@ macro_rules! _run { | |||
65 | $crate::not_bash::run_process(format!($($expr),*), false, Some($stdin)) | 66 | $crate::not_bash::run_process(format!($($expr),*), false, Some($stdin)) |
66 | }; | 67 | }; |
67 | } | 68 | } |
68 | pub(crate) use _run as run; | 69 | pub use crate::run; |
69 | 70 | ||
70 | pub struct Pushd { | 71 | pub struct Pushd { |
71 | _p: (), | 72 | _p: (), |
@@ -153,7 +154,17 @@ fn run_process_inner(cmd: &str, echo: bool, stdin: Option<&[u8]>) -> Result<Stri | |||
153 | 154 | ||
154 | // FIXME: some real shell lexing here | 155 | // FIXME: some real shell lexing here |
155 | fn shelx(cmd: &str) -> Vec<String> { | 156 | fn shelx(cmd: &str) -> Vec<String> { |
156 | cmd.split_whitespace().map(|it| it.to_string()).collect() | 157 | let mut res = Vec::new(); |
158 | for (string_piece, in_quotes) in cmd.split('\'').zip([false, true].iter().copied().cycle()) { | ||
159 | if in_quotes { | ||
160 | res.push(string_piece.to_string()) | ||
161 | } else { | ||
162 | if !string_piece.is_empty() { | ||
163 | res.extend(string_piece.split_ascii_whitespace().map(|it| it.to_string())) | ||
164 | } | ||
165 | } | ||
166 | } | ||
167 | res | ||
157 | } | 168 | } |
158 | 169 | ||
159 | struct Env { | 170 | struct Env { |