Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

copy-from-rbenv now checks that rbenv dirs exist and aren't empty #161

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ravenhall
Copy link

While looking at open issues, I happened to run 'make' on my (working, up to date) plenv installation. The script author/copy-from-rbenv.sh trashed my plenv install. This patch checks that ~/.rbenv, ~/.rbenv/completions, and ~/.rbenv/libexec exist and are not empty before whacking the corresponding plenv directories.

Git status revealed the damage:
deleted: completions/plenv.bash
deleted: completions/plenv.fish
deleted: completions/plenv.zsh
deleted: libexec/plenv
deleted: libexec/plenv---version
deleted: libexec/plenv-commands
deleted: libexec/plenv-completions
deleted: libexec/plenv-exec
deleted: libexec/plenv-global
deleted: libexec/plenv-help
deleted: libexec/plenv-hooks
deleted: libexec/plenv-init
deleted: libexec/plenv-local
deleted: libexec/plenv-prefix
deleted: libexec/plenv-rehash
deleted: libexec/plenv-root
deleted: libexec/plenv-sh-rehash
deleted: libexec/plenv-sh-shell
deleted: libexec/plenv-shims
deleted: libexec/plenv-version
deleted: libexec/plenv-version-file
deleted: libexec/plenv-version-file-read
deleted: libexec/plenv-version-file-write
deleted: libexec/plenv-version-name
deleted: libexec/plenv-version-origin
deleted: libexec/plenv-versions
deleted: libexec/plenv-whence
deleted: libexec/plenv-which

@ispyhumanfly
Copy link

This is good to go can we get this merged in @tokuhirom ?

libexec/plenv-which
cp ~/.rbenv/libexec/* libexec/
cp ~/.rbenv/completions/* completions/
if [[ "$(ls -A ~/.rbenv)" && "$(ls -A ~/.rbenv/libexec)" && "$(ls -A ~/.rbenv/completions)" ]];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it enough to use -d file test operator instead of ls -A ? ls -A some_path shows error if some_path does not exist like ls: /Users/shohei.yoshida/.rbenv: No such file or directory.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am fine with using -d if that's preferred.

perl -i -pe 's/version="[0-9.]+"/version="$ENV{GIT_REVISION}"/' libexec/plenv---version
perl -i -pe 's!print_summaries commands local global shell install uninstall rehash version versions which whence!print_summaries commands local global shell install uninstall rehash version versions which whence list-modules migrate-modules install-cpanm!; s!%-9s!%-17s!' libexec/plenv-help
else
echo "rbenv not detected for this user, no changes were made."
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation of else block is different from then block. IMO Indent size should be 2 space because other scripts uses it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants