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

Allow scripts to be run from outside user dir #28

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

rzr
Copy link

@rzr rzr commented Oct 25, 2019

Change-Id: Ic8aba9e8372d31b6e11399f3500b66842f7a3f7d
Signed-off-by: Philippe Coval rzr@users.sf.net

Change-Id: Ic8aba9e8372d31b6e11399f3500b66842f7a3f7d
Signed-off-by: Philippe Coval <rzr@users.sf.net>
@jsoref
Copy link
Owner

jsoref commented Nov 13, 2019

From memory, none of the "obvious" approaches is particularly reliable:

https://stackoverflow.com/questions/242538/unix-shell-script-find-out-which-directory-the-script-file-resides

To deal with this more or less requires a number of changes:

  • Switching from posix sh to something else (it's vaguely possible to do this with Bash)

An alternative approach would be to rewrite the code in perl/python/node.js

(I recently ran into a case where npm's nodeenv writes a script that is sh friendly, and the way it does it is by hard coding the absolute path to the installation directory -- alternatively, you can try running it inside bash...)

@jsoref
Copy link
Owner

jsoref commented Nov 13, 2019

FWIW, this fails for the symlink case.

If your path has a directory bin which has a symlink to an f file in a directory spelling (with this repository), this code will resolve the path to bin, whereas the correct path is actually spelling.

Also, while you're probably running on Linux, I use Linux and macOS. On macOS, readlink doesn't have the same -f behavior that people normally suggests to deal w/ that edge.

It's really quite painful to get this right.

@jsoref jsoref force-pushed the master branch 2 times, most recently from 2b7d0ac to 9ffb4a2 Compare February 12, 2020 00:38
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.

None yet

2 participants