On 2020-01-28 at 18:28:55, Junio C Hamano wrote: > "brian m. carlson" writes: > > > +convert_expected () { > > + file="$1" && > > + for i in one three_file master master2 one_tree three two two2 three2 > > + do > > + sed -e "s/$(test_oid --hash=sha1 "$i")/$(test_oid "$i")/g" \ > > + "$file" >"$file.tmp" && > > + mv "$file.tmp" "$file" > > + done > > +} > > Perhaps we can avoid rewriting the same file that many times, by > feeding the mapping to a single invocation of sed? E.g. > > sedScript= > for i in one three_file master master2 one_tree three two two2 three2 > do > i="s/$(test_oid --hash=sha1 $i/$(test_oid $i)/g" > sedScript=$sedScript${sedScript:+;}$i" > done && > sed -e "$sedScript" "$file" >"$file.new" && > mv "$file.new" "$file" This is a good idea. We could also write a small sed script to a file at the beginning and invoke it with sed -f. That's portable (POSIX supports it) and should be easy and efficient to do. -- brian m. carlson: Houston, Texas, US OpenPGP: https://keybase.io/bk2204