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

redo-subst #4

Closed
wants to merge 1 commit into from
Closed

redo-subst #4

wants to merge 1 commit into from

Conversation

akrennmair
Copy link

I implemented a simple command redo-subst that helps with auto-generating lists of dependencies in certain cases. It takes two file suffixes and a list of file names, and generates a list of file names where the (matching) first suffix is substituted with the second suffix.

This allows constructs like these but in a more reliable fashion than ls ... | sed ...:

DEPS=`redo-subst .c .o foo/*.c`
redo-ifchange $DEPS
cc -o $3 $DEPS

This is also basically the first real Python code that I wrote in my life. If the code is too bad, feel free to correct me.

Best regards,
Andreas

@apenwarr
Copy link
Owner

Hmm, this looks reasonably nice, but I'm worried about adding commands that expand the redo API unnecessarily. What's "not reliable" about ls and sed?

BTW, I've learned a lot about sh since starting to work on redo. Nowadays what I would probably use is something like this:

DEPS=$(for d in foo/*.c; do echo "${d%.c}.o"; done)

...which is pretty easy, and doesn't require any forking, so it's faster than either ls/sed or your redo-subst.

So I appreciate the contribution, but I think it's best not to include it.

Thanks!

This pull request was closed.
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

Successfully merging this pull request may close these issues.

2 participants