Dump files into a self-extracting shell script

Project URL: GitHub - wh0/dump

find . \( -type d -printf 'mkdir %p\n' \) -o \( -type l -printf 'ln -s %l %p\n' \) -o \( -type f -printf "cat >%p <<'DUMP_EOF'\n" -exec cat {} \; -printf 'DUMP_EOF\n' -executable -printf 'chmod +x %p\n' \)

:point_up: that’s it!

I’ve been interested in getting glitch projects to work together lately. one thing that comes up is there’s a set of files that I need to put in multiple projects. now, a proper way to do this would be to go through git. and that all involves various copy and pasting of git URLs, weird git checkout invocations with FETCH_HEAD, and other things. it’s all kind of complicated, really.

so instead of all that, I figured I’d bundle up the files into a great piece of text that I could paste into the project terminal. for a while I was using a concoction of tar and base64. but then I started thinking, “what if this paste-able thing could be the source of truth?” that, if I wanted to edit this common set of files, I could just edit the piece of text instead of unpacking it somewhere, editing it, and re-packing it?

and I figured I could write a little program to generate a readable and editable shell script that sets up the desired files.

and then that little program somehow shrank down into a horrible find one-liner. but I like it.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.