Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Lookup shell from running binary on systems with a /proc fs #1098

Closed
wants to merge 1 commit into from

3 participants

@richo
Owner

Any reason not to do this?

@Dunnzilla

I tested on Cygwin and it succeeds.

$ basename $(readlink -f /proc/$$/exe)
bash
@richo
Owner

Awesome thanks @Dunnzilla

@mpapis
Owner

we are interesting in the name that was used to start the shell, not the binary used

$ sh -
$ ps -p $$ -o comm=
sh
$ basename $(readlink -f /proc/$$/exe)
bash
@mpapis
Owner

man bash:

If bash is invoked with the name sh, it tries to mimic the startup behavior of historical versions of sh as closely as possible, while conforming to the POSIX standard as well.

@mpapis
Owner

maybe we should write requirements for cygwin and just include ps on the list?

@richo
Owner

There has to be a better way for all platforms. I'll have a think about it.

@mpapis
Owner

@richo I've spent few days to get to the current code, could not find anything better, maybe you will have more luck ... but do not push to much, remember plans for RVM2 - maybe better to put our efforts there ...

@mpapis
Owner

Maybe I missed to mention the most important bit of information, the sh shell is used by X server, this leads to loading rvm in unsupported environment and giving code errors on stderr - this leads to breaking server. This issue was observed on Fedora 16 or 17 and some Ubuntu or Debian. Also we use strictly bash / zsh compliant code in rvm and those loading from non bash/zsh shell should be not allowed.

In RVM2 all the code will be handled by internal (separate) shell binary, communication with other shells will be made via code evaluation - so only minimal efforts will be required to integrate as most of the code will be handled and tested using one shell.

@richo richo was assigned
@richo
Owner

Closing until I've had a change to think about this a bit more.

@richo richo closed this
@Dunnzilla

FWIW, the problem is not that 'ps' is missing from Cygwin. The problem is 'ps' on Cygwin does not support the -o flag, on which rvm relies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 9 additions and 2 deletions.
  1. +9 −2 scripts/functions/installer
View
11 scripts/functions/installer
@@ -841,9 +841,16 @@ setup_etc_profile()
# /etc/profile.d/rvm.sh # sh extension required for loading.
#
+
+if test -d /proc
+then
+ shell=\$(basename \$(readlink -f /proc/\$\$/exe))
+else
+ shell=\"\`ps -p \$\$ -o comm=\`\"
+fi
if [ -n \"\${BASH_VERSION:-}\" -o -n \"\${ZSH_VERSION:-}\" ] &&
- test \"\`ps -p \$\$ -o comm=\`\" != dash &&
- test \"\`ps -p \$\$ -o comm=\`\" != sh
+ test \"\$shell\" != dash &&
+ test \"\$shell\" != sh
then
: rvm_stored_umask:\${rvm_stored_umask:=\$(umask)}
Something went wrong with that request. Please try again.