Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4f018189 authored by Sonny Sasaka's avatar Sonny Sasaka Committed by Gerrit Code Review
Browse files

Merge "Floss: Use shell-words splitter for btclient"

parents f526b027 b73d9729
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ dbus_macros = { path = "../dbus_projection/dbus_macros" }

futures = "0.3.13"
num-traits = "0.2"
shell-words = "1.1.0"
tokio = { version = "1", features = ['bytes', 'fs', 'io-util', 'libc', 'macros', 'memchr', 'mio', 'net', 'num_cpus', 'rt', 'rt-multi-thread', 'sync', 'time', 'tokio-macros'] }

clap = "2.33.3"
+27 −8
Original line number Diff line number Diff line
@@ -405,7 +405,7 @@ async fn start_interactive_shell(
        }
    });

    loop {
    'readline: loop {
        let m = rx.recv().await;

        if m.is_none() {
@@ -570,15 +570,34 @@ async fn start_interactive_shell(
                    break;
                }
                Ok(line) => {
                    let mut args = line.split_whitespace();
                    let cmd = args.next().unwrap_or("");
                    // Currently Chrome OS uses Rust 1.60 so use the 1-time loop block to
                    // workaround this.
                    // With Rust 1.65 onwards we can convert this loop hack into a named block:
                    // https://blog.rust-lang.org/2022/11/03/Rust-1.65.0.html#break-from-labeled-blocks
                    // TODO: Use named block when Android and Chrome OS Rust upgrade Rust to 1.65.
                    loop {
                        let args = match shell_words::split(line.as_str()) {
                            Ok(words) => words,
                            Err(e) => {
                                print_error!("Error parsing arguments: {}", e);
                                break;
                            }
                        };

                        let (cmd, rest) = match args.split_first() {
                            Some(pair) => pair,
                            None => break,
                        };

                        if cmd.eq("quit") {
                            break 'readline;
                        }

                        handler.process_cmd_line(&String::from(cmd), &rest.to_vec());

                        break;
                    }
                    handler.process_cmd_line(
                        &String::from(cmd),
                        &args.map(String::from).collect::<Vec<String>>(),
                    );

                    // Ready to do readline again.
                    semaphore_fg.add_permits(1);
                }