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

Fix weird directory ... not found #3

Merged
merged 1 commit into from
Jul 22, 2019

Conversation

abravalheri
Copy link
Contributor

@abravalheri abravalheri commented Jul 20, 2019

Hi @padde thank you very much for the amazing plugin!
I have being using it for a while now, but in the last weeks when I switched operating system, I have been dealing with a very weird directory ... not found error (when the directory does exist).

It turns out, some OSs have sh linked to other kinds of shells, that are not
bash-like. For example, Ubuntu uses dash (ref: https://wiki.ubuntu.com/DashAsBinSh).

Some of those shells do not provide the built-in command source, which causes
the function JumpCommand to fail with an 127 error code.

Since jump.vim assumes all errors are caused by non-existing directories,
the resulting error message was very enigmatic and frustrating…

This PR, tries to solve that by enforcing bash, that is pretty much present every where. While it is not ideal to assume bash is omnipresent, we cannot assume all built-in sh support the source command either :(
This would be the best compromise I think (especially considering for example that Ubuntu is quite popular).

It turns out some OSs have `sh` linked to other kinds of shells, that are not
`bash`. For example, Ubuntu uses `dash` (ref:
https://wiki.ubuntu.com/DashAsBinSh).

Some of those shells do not provide the built-in command `source`, which causes
the function `JumpCommand` to fail with an 127 error code.

Since `jump.vim` assumes all errors are caused by non-existing directories,
the resulting error message was very enigmatic and frustrating…
@padde
Copy link
Owner

padde commented Jul 22, 2019

@abravalheri thank you for your contribution! Good catch, I stumbled across this in another project too.

I personally don't have bash installed in all my machines where I use this plugin. My preference would be to change the script to be POSIX compliant so it's portable. In this case this means using the . command over source. Would you mind changing it this way please?

Thank you!

@abravalheri
Copy link
Contributor Author

Hi @padde, unfortunatelly it doesn't seem to be that simple, at least in Ubuntu.

Just replacing:

-  return system("bash -c 'source " . g:autojump_executable . " && " . a:cmd . " " . a:args . " > /dev/null && pwd'")
+  return system("sh -c '. " . g:autojump_executable . " && " . a:cmd . " " . a:args . " > /dev/null && pwd'")

still generates a 127 error.

+  return system("bash -c '. " . g:autojump_executable . " && " . a:cmd . " " . a:args . " > /dev/null && pwd'")

works though

By checking /usr/share/autojump/autojump.sh on Ubuntu, you can see that the file does not support dash and doesn't follow POSIX standards (the file itself uses source instead of .).

@padde
Copy link
Owner

padde commented Jul 22, 2019

Oh well if we depend on bash anyway, we might as well leave the more readable source in there 😉

@padde padde merged commit c59a354 into padde:master Jul 22, 2019
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.

2 participants