Fish has had a sh-compatible export for nearly a decade now [0][1].
Unfortunately, jenv's implementation isn't fully-featured. Unlike the upstream
version, it breaks on relatively-common inputs like `export X=0 Y=1`.
As fish is predominantly an interactive shell, this change shouldn't break
much, especially given that only older LTS distributions versions still ship
Fish 2.x in 2022.
[0]: https://github.com/fish-shell/fish-shell/pull/1833
[1]: https://github.com/fish-shell/fish-shell/blob/3.4.1/share/functions/export.fish
using `ps` to detect the shell fails in some cases (For me, it is using
a docker container to run an x86 OS image on an M1 Mac - the process is
is /usr/bin/qemu-x86_64 /bin/bash)
Using the $[SHELL]-VERSION environment variables is probably the most
fool-proof way to detect the shell.
using `ps` to detect the shell fails in some cases (For me, it is using
a docker container to run an x86 OS image on an M1 Mac - the process is
is /usr/bin/qemu-x86_64 /bin/bash)
Using the $[SHELL]-VERSION environment variables is probably the most
fool-proof way to detect the shell.
Right now, jenv init only partially runs if it can't detect the shell.
Since bash-derived shells are probably the most common, let's just
assume that it is bash-compatible.
(I ran into this running from a x86 Docker container on an M1 Mac, where we
currently detect the shell as qemu-x86)
This commit updates `jenv-add` to handle version numbers which are > 1.8 and do not include a `.` _but may include a non-numeric suffix_. For example, this is the case when installing JDK15 on Ubuntu 20.04 LTS from the Canonical PPA. In this case the version number parsed by `jenv` is `15-ea` ("ea" is for early adopter I believe).
The old `jenv` logic would only parse a single alias for this JRE, the full string `15-ea`. This is especially undesirable since the `-ea` suffix is likely to go away in the near future, either via PPA updates or distro updates.
This commit updates the `sed` call which parses `JAVA_SHORTESTVERSION` to look for an _optional_ `.`, rather than a required one.
For example,
```shell
$ sed 's/\([0-9]\+\).*/\1/' <<< 15-ea
15
```
This change _should_ not change other existing parsing behavior, e.g.
```shell
$ sed 's/\([0-9]\+\).*/\1/' <<< '1.8.0'
1
```
```shell
$ sed 's/\([0-9]\+\).*/\1/' <<< '14.0.1'
14
```
Keep JDK_HOME environment variable in sync with JAVA_HOME to avoid discrepancies within the same (i.e. not new or reloaded) shell whenever `jenv init -` is being executed.