Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Globs #48

Open
casey opened this issue Jun 2, 2021 · 2 comments
Open

Globs #48

casey opened this issue Jun 2, 2021 · 2 comments

Comments

@casey
Copy link
Collaborator

casey commented Jun 2, 2021

There are some kinds of string expansion that the shell does that it would be nice to support. They're very different features, but they all fall into the category of "modify this string in some useful way", so I thought I'd put them all in the same issue.

They could be supported separately, but it might also be useful to have something that does all the expansions you might want, in a reasonable order, with a single helper. Like Expand("~/$SRC/**/*.rs"). The reasonable order is probably whatever bash does.

Globs

$ cp *.txt foo
cmd!("cp", ExpandGlob("*.txt"), "foo");

It would also be nice to support ** globs:

$ cp src/**/*.rs foo
cmd!("cp", ExpandGlob("src/**/*.rs"), "foo");

Variable interpolation

$ cd $HOME/bin
cmd!("cd", ExpandVar("$HOME/bin"));

Tilde expansion

$ cat ~rodarmor/src/agora/src/main.rs
cmd!("cat", ExpandTilde("~rodarmor/src/agora/src/main.rs"));

Brace expansion

$ mv foo.{txt,bin}
cmd!("mv", ExpandBrace("foo.{txt,bin}"));
@soenkehahn
Copy link
Owner

I like this idea. I'm a bit worried about having to re-implement bash's expansion behavior.

@casey
Copy link
Collaborator Author

casey commented Jun 2, 2021

I think there are crates for most of these things:

Brace expansion is the craziest, and there's no crate for that.

One nice thing is that these things could all be tested against bash itself, to make sure that they behave the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants