Commit graph

64 commits

Author SHA1 Message Date
Roman Levin
ac5dce9014 Remove another fish psub usage 2020-02-17 21:38:46 +01:00
Roman Levin
19ae300eb8 Fix fish shell initialization
Since fish 3.10 at least, the current way of loading rbenv in `fish` is misbehaving, at least in some environments:

```
source: Error encountered while sourcing file '/var/folders/pj/jn249gcn7ddfrjzj2_9mxjhw0000gp/T//.psub.f0iJSWRByB':
source: No such file or directory
```

This changes the initialization to the method recommended by a `fish` developer here: https://github.com/fish-shell/fish-shell/issues/6613#issuecomment-586679958
2020-02-17 21:38:46 +01:00
Mislav Marohnić
569d464d36 Remove fish completion script
fish ships with a much more capable rbenv completion script since fish 2.0.

Fixes #1212
2020-01-28 17:47:59 +01:00
Ryan Davis
1a8b5e04a9 Fixed rbenv init - output to work w/ no args and bash's set -u. 2017-11-06 13:59:04 -08:00
Jeff Kowalski
a81da8d864 Revert quoting change in previous commit; adjust test to match code
Revert back to original quoting style used before previous commit.
Adjust init.bats to reflect changes for successful tests.
2017-05-16 13:36:06 -07:00
Jeff Kowalski
be2e606fbd Prefer 'set' over 'setenv' for fish shell
The setenv function in fish shell has changed dramatically in
75600b6b53
It now conforms to the csh version, which takes at most two arguments.
In this init script, the form
    setenv PATH prepend_something $PATH
had been used, which had too many arguments.
Since setenv isn't a native command in fish, a suitable replacement is
to use the "set -gx" command, which can consume multiple arguments.
2017-04-06 23:55:48 -07:00
Donald Merand
8b0b51a166 convert references to '.' to 'source' for fish shell 2016-02-20 10:27:39 -05:00
Mislav Marohnić
a9a9636d1e Tweak sanitizing shell name
Handles situation when the output is `/bin/shell- args...`. First strip
away the arguments, then the trailing dash.
2015-12-24 13:23:01 +01:00
Daniel Hahler
32030e2ed9 Fix shell version when invoked from a script
When invoked from a shell script, `$(rbenv init -)` did not get the
shell name correct.
It needs to look at the `args` value from `ps`.

Ref: https://github.com/yyuu/pyenv/issues/373
2015-12-24 13:21:22 +01:00
Jason Karns
2dcb9d0611 completions for rbenv-init 2015-11-20 09:20:01 -05:00
Mislav Marohnić
6913fee89a If there is .bashrc but no .bash_profile, recommend the former
This is for Linux desktop platforms that have Terminal application
configured to start shells in interactive but not login mode. Creating a
`~/.bash_profile` would also cause `~/.profile` to not run, which might
be a problem on Ubuntu which ships with a default `~/.profile`.
2015-10-26 15:45:52 +01:00
Mislav Marohnić
0f44c57d08 Fix eval'ing multiline sh-* command output with bash 2015-10-12 01:33:17 +02:00
Mislav Marohnić
efb187f26f Merge pull request #663 from kevinburke/use-command
Use `command` to run rbenv rehash
2015-10-11 04:04:46 +02:00
Mislav Marohnić
c101052a7f Fix eval'ing multiline sh-* command output with fish 2015-10-10 21:48:40 +02:00
Mislav Marohnić
c43928a8e4 Merge pull request #731 from blueyed/init-no-basename-for-shell
rbenv-init: do not use basename for $shell
2015-10-10 18:33:52 +02:00
Mislav Marohnić
9e664b5d27 Suggest that rbenv should be loaded at end of shell rc file
Closes #725
2015-09-12 15:27:32 -07:00
Daniel Hahler
4ea7d0849b rbenv-init: do not use basename for $shell
This can be done using bash directly.
2015-05-10 16:17:35 +02:00
Kevin Burke
c9a96c9f79 Use command to run rbenv rehash
In the event that `eval "$(rbenv init -)"` is called from a function named
rbenv (which I do to get rbenv to load lazily in my shell), evaluating the
phrase `rbenv rehash` will cause the outer function to run again (causing an
infinite loop).

This change makes it clear you want the command named rbenv and not a function
which may exist in the environment.
2014-11-28 21:16:14 -08:00
Mislav Marohnić
39cde6fc95 Merge pull request #528 from sstephenson/dylib
Speed up rbenv by dynamically loading compiled command
2014-10-15 18:19:54 +02:00
Mislav Marohnić
e2173df4aa Revert "Don't duplicate shims in PATH"
Too many of our users have a shell initialization set up that
inadvertently duplicates some or most of the entries in their PATH,
bringing the system paths again in front of rbenv's shims. If this was a
nested shell (a typical scenario when starting up tmux), `rbenv init`
would get eval'd again but this time, shims won't get added to the front
of the PATH and would only stay and the end of the path, effectively
rendering them useless.

I tried to argue that this is a user problem rather than rbenv's, but I
can't fix everybody shell init when they report bugs. Instead, let's
revert to simpler times in rbenv where we just roll along with the
duplication and don't ask any questions.

This reverts commit 03fa148e81.

Fixes #369
2014-10-15 01:43:24 +02:00
Mislav Marohnić
8bac958994 Stop using abs_dirname() in rbenv-init
It's slow and not necessary since we expect `$0` to already be expanded.

In tests this change forces us to deal with some relative paths, but
it's not a big deal. The `rbenv init -` output in the most common case
will be the same as before:

    source '/home/myuser/.rbenv/libexec/../completions/rbenv.bash'
2014-10-13 04:12:34 +02:00
Mislav Marohnić
13a474c4e9 Get rid of explicit exit in fish branch of rbenv-init
Allows for code to be added to the end of the script which will not
mysteriously fail to run for fish shell.
2014-06-03 00:39:34 +07:00
Mislav Marohnić
1a6bada94c Fix detecting parent shell on OpenBSD and Cygwin
It seems that "comm" header can't be relied on cross-platform, but that
"ucomm" is more portable. I have no idea whether it's the right value to
use here, but it seems to be doing the job.

Also strip trailing whitespace because OpenBSD 5.4 `ps` output is padded
with spaces for some reason.

Fixes #489
2014-01-02 22:36:03 +01:00
Mislav Marohnić
be5e1a4ded Improve rbenv init instructions for fish
Fish user config file `~/.config/fish/config.fish` loads for every
instance of fish shell, not just interactive ones. Since it's
unnecessary and dangerous to eval `rbenv init -` output in
non-interactive shells, wrap the invocation in a conditional that checks
if the current shell is interactive.

Fixes #501
2013-12-06 16:45:22 +01:00
Mislav Marohnić
3300587c6b strip initial - from the name of shell process
Avoids the case where shell detection would result in
`basename "-bash"` invocation, triggering the error:

    basename: illegal option -- b

fixes #462
2013-10-07 14:19:37 +02:00
Mislav Marohnić
878bd87328 reliably detect parent shell in rbenv init
`$SHELL` variable is a terrible way of detecting the current shell
because it's not even supposed to reflect the current shell; it's meant
for keeping the value of the default shell for programs to start.

If an explicit `<shell>` argument wasn't passed to `rbenv init`, it
tries to detect the shell by getting the name of its parent process. If
this fails, it falls back on the value of `$SHELL` as before.

Furthermore, `rbenv init` will set the RBENV_SHELL variable in the
current shell to the value of the detected shell so that `sh-shell` and
`sh-rehash` commands don't have to repeat the detection.
2013-10-07 03:24:45 +02:00
Mislav Marohnić
e97326845c Ubuntu fix: don't use . in place of source
If `rbenv init -` outputs `.` in place of `source` and that gets eval'd
by the desktop manager via `~/.profile`, it chokes and prevents the user
from logging in.

Fixes #457
2013-10-03 16:12:24 +02:00
Mislav Marohnić
5ae2cac088 fix rbenv() function in ksh and dash
ksh syntax becomes:

    function rbenv {
      typeset command

`typeset` only declares a local variable if there's an explicit
`function` declaration; otherwise the variable leaks.

Other shells use this syntax:

    rbenv() {
      local command

This is for dash compatibility, which supports neither `function` nor
`typeset`.

references #205, fixes #408
2013-09-28 16:12:53 +02:00
Mislav Marohnić
31fab8cdae cleanup in fish
Use process subtitution syntax:

    . (rbenv init -|psub)

instead of:

    eval (rbenv init -)

because the latter doesn't work well with newlines.
2013-09-28 16:12:43 +02:00
Yamashita Yuu
5bfec84432 add fish shell support 2013-09-28 16:11:02 +02:00
Mislav Marohnić
bdcc2e1790 check if completion script is readable
fixes #444
2013-09-09 09:53:50 +02:00
James FitzGibbon
81bb14e181 bail out early if readlink is not available
readlink comes from GNU coreutils.  On systems without it, rbenv used to
spin out of control when it didn't have readlink or greadlink available
because it would re-exec the frontend script over and over instead of the
worker script in libexec.

Fixes #389
2013-06-07 19:16:38 +02:00
Shohei Yamasaki
2bbf49b2f5 replace tab with spaces 2013-03-23 22:37:25 +09:00
Tim Pope
03fa148e81 Don't duplicate shims in PATH 2013-03-20 13:16:02 +01:00
YanhaoYang
13f36e0416 rbenv(): preserve multiline output of sh-* commands 2013-02-22 15:42:31 +01:00
Sam Stephenson
37eca782cc Documentation tweaks 2012-12-29 22:05:04 -06:00
Mislav Marohnić
3436bddaea new-style documentation for most commands 2012-12-29 23:34:53 +01:00
Mislav Marohnić
3060578e3b use typeset instead of local in rbenv() function
This is to insure portability to ksh.

Fixes #205, references #209
2012-12-13 06:01:26 +01:00
Ruben Verborgh
cf28136003 speed up rbenv-init
Use `rbenv-commands` instead of `rbenv commands`. The latter
unnecessarily goes through `rbenv` executable.

Fixes #254
2012-12-13 00:18:32 +01:00
Andrew Marshall
9c43fa9161 Prevent $command from leaking outside of function 2012-02-04 18:05:43 -05:00
John Williams
f40bc773d2 Allow init arguments to be in any order. 2012-01-17 08:50:40 -06:00
Sam Stephenson
ee5ad02d42 Add --no-rehash option to rbenv-init (#170) 2011-12-25 20:59:24 -05:00
Sam Stephenson
288c6b3f09 Go with paren-style function definition 2011-12-24 17:49:22 -05:00
Michael Grubb
7e83e07cf3 Made ksh portability changes
Added specific message for ksh in identifying the proper shell
initialization file.

Changed rbenv functiond definition to be more portable.
Shell functions should be defined by using the function command or
using the parenthesis grammar, but using both is not portable:

rbenv() {...  -or-
function rbenv { ...
2011-12-15 14:54:38 -06:00
Sam Stephenson
0632325a43 Set RBENV_DEBUG=1 to see what's going on under the hood 2011-09-12 10:11:59 -05:00
Sam Stephenson
7ac964353f RBENV_HOME -> RBENV_ROOT 2011-09-11 11:58:57 -05:00
Sam Stephenson
c6ce8fafd8 Merge remote-tracking branch 'alexrinass/systemwide' 2011-09-11 11:28:54 -05:00
Sam Stephenson
fb6eee26d4 Only shift if an argument is passed. Fixes #78. 2011-09-10 20:10:07 -05:00
Sam Stephenson
1ba2ce0cb6 Fix quoting in rbenv function 2011-09-10 20:10:07 -05:00
Alexander Rinass
5130f0464a Support install locations other than $HOME/.rbenv.
Define RBENV_HOME env variable in libexec/rbenv and let all script delegates use this variable to determine rbenv's install location.
2011-08-25 09:28:01 +02:00