Use bash globbing to set RUBIES#424
Use bash globbing to set RUBIES#424ktchen14 wants to merge 1 commit intopostmodern:masterfrom ktchen14:master
Conversation
|
A shell-based solution would need to be portable to zsh since chruby support bash and zsh. For the moment, you can source chruby before you set your exa alias for a fix. |
havenwood
left a comment
There was a problem hiding this comment.
This would need to either be implemented portably for bash/zsh or you could do a if statement with a bash- and zsh-specific version.
Adding proper ordering would be a real win.
share/chruby/chruby.sh
Outdated
| CHRUBY_VERSION="0.3.9" | ||
| RUBIES=() | ||
|
|
||
| saveglob="$(shopt -p nullglob dotglob)" |
There was a problem hiding this comment.
In zsh, the shopt equivalent would be setopt.
| shopt -s nullglob | ||
| shopt -u dotglob | ||
| for dir in "$PREFIX/opt/rubies" "$HOME/.rubies"; do | ||
| [[ -d "$dir" && -n "$(ls -A "$dir")" ]] && RUBIES+=("$dir"/*) |
There was a problem hiding this comment.
Another thing to consider is the sort order. In zsh, you can get a proper numeric sort fairly easily, so 2.10 is greater than 2.9.
Here is a zsh one-liner.
echo "${(@n)RUBIES}"Or to print each Ruby in order:
printf "%s\n" "${(@n)RUBIES:t}"|
See #278 for a stab at numeric sorting. We discussed the possibility of creating a shell library for portable numeric sorting, since it's an annoying gap. I'm for switching to a portable shell solution but think it should fix the numeric sorting issue too. |
|
@havenwood I just pushed a new version of the code which should be |
|
Also this doesn't handle ordering. That looks hard to do in a portable fashion and I believe is out of scope for this PR. |
|
Ping. Please let me know if there are any changes I should make or if I should close this PR. Thanks! |
This is an alternative to #406. It fixes #413 and uses bash native functionality instead of
lsat all. The impetus for this change is that an alias tolsbreakschruby. Specifically in my case I have:alias ls=exaWhich doesn't have a
-Aflag.