Speed up rbenv-rehash by using hard links

This commit is contained in:
Sam Stephenson 2011-08-03 22:57:27 -05:00
parent 7ce04a6e03
commit fffb29d695

View file

@ -1,15 +1,19 @@
#!/usr/bin/env bash -e #!/usr/bin/env bash -e
create_prototype_shim() {
cat > .rbenv-shim <<SH
#!/usr/bin/env bash -e
exec rbenv exec "\${0##*/}" "\$@"
SH
chmod +x .rbenv-shim
}
make_shims() { make_shims() {
local glob="$@" local glob="$@"
for file in $glob; do for file in $glob; do
local shim="${file##*/}" local shim="${file##*/}"
cat > "$shim" <<SH [ -e "$shim" ] || ln -f .rbenv-shim "$shim"
#!/bin/sh
exec rbenv exec $shim "\$@"
SH
chmod +x "$shim"
done done
} }
@ -17,6 +21,7 @@ mkdir -p "${HOME}/.rbenv/shims"
cd "${HOME}/.rbenv/shims" cd "${HOME}/.rbenv/shims"
rm -f * rm -f *
create_prototype_shim
make_shims ../versions/*/bin/* make_shims ../versions/*/bin/*
shopt -s nullglob shopt -s nullglob
@ -26,3 +31,5 @@ shopt -u nullglob
for script in ${RBENV_REHASH_PLUGINS[@]}; do for script in ${RBENV_REHASH_PLUGINS[@]}; do
source $script source $script
done done
rm -f .rbenv-shim