I have this zsh function that finds the readme of github projects from their root link (e.g., https://github.com/Mortennn/Dozer -> https://github.com/Mortennn/Dozer/blob/master/README.md). Because the casing of this file is inconsistent (e.g., readme Readme READMe
), I am currently trying all possible case permutations, which is very slow.
Is there a more efficient solution?
#There are lots of stuff here, just ignore them. You can ignore this code completely, too. The question is self-sufficient.
for readme in "${(0@)$(permute-case readme)}"
do
i2="${i}/blob/master/${readme}.md"
silence wget --spider "$i2" && break
i2="${i}/blob/master/${readme}.rst"
silence wget --spider "$i2" && break
done