Recently Written · git

tmpl

Insanely simple templates

git clone https://github.com/equwal/tmpl

Log | Files | Refs


sh/for-find (452 bytes)

1 # Yes, it really is this hard to do
2 # and it is broken on GNU non-POSIX non-+ support.
3 save () {
4     for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
5     echo " "
6 }
7 
8 
9 findarray () {
10     find "$@" -exec sh -c "for i do printf %s\\\\n \"\$i\" \\
11     | sed \"s/'/'\\\\\\\\''/g;1s/^/'/;\\\$s/\\\$/' \\\\\\\\/\"
12     done" dummy '{}' +
13 }
14 
15 old=$(save "$@")
16 eval "set -- $(findarray path)"
17 for i do <++> ; done
18 eval "set -- $old"