I have a 'collection of boxed terminal commands', but now need local result from one command for another

I've got a installation script written in rust
that first once gone through the configuration wizard,
runs a bunch of linux commands for installing.

So what I do is that once configuration is set, is to collect all the
methods that needed to be run and then firing them one by one.
My issue is that at least one of these commands need to know the
destination path of a previous command for file extraction.

What I'm hoping I could do is to do something like this:

fn main() {
    let mut x = 5;
    add_mut(&mut x);
    println!("x == {}", x);
}

fn add_mut(x: &mut i32) {
    *x += 1;
}

But then pass the x on to a... collection of boxed commands?
Not sure what to call it.
But I get borrowing issues with it.

Below is an example that doesn't use the duct::cmd library,
so consider the issue in the code below as simplified:

[edit]

I'm beginning to think I could also use a database for this
and save and retrieve the path there.
Would that be a better option?

You can use Cell for this: Rust Playground

1 Like

Looks like I don't need mut anymore as well.
Rust Playground