Fix invocation of b4.sh through a symlink
PATCH 1/1 Fix invocation of b4.sh through a symlink
If b4 in your $PATH is a symlink pointing to b4.sh, $SCRIPT_TOP points to the directory containing the symlink, and b4/command.py cannot be found.
Fix this by following any symlinks, if present.
After this it works for being invoked through either an alias, symlink, or plain path.
---
Stack Overflow tells me "readlink -f" is not supported on OS X and some BSDs. Do we care?
--- b4.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
b4.sh +1 -1
@@ -3,6 +3,6 @@ # Run b4 from a git checkout. # -SCRIPT_TOP="${SCRIPT_TOP:-$(cd "${BASH_SOURCE%/*}" && pwd)}" +SCRIPT_TOP="${SCRIPT_TOP:-$(dirname $(readlink -f $0))}" exec env PYTHONPATH="${SCRIPT_TOP}" python3 "${SCRIPT_TOP}/b4/command.py" "${@}"
Signature · 1 line
2.17.1
Quoted 6 lines · Geert Uytterhoeven
If b4 in your $PATH is a symlink pointing to
b4.sh, $SCRIPT_TOP points to the directory containing the symlink, andb4/command.pycannot be found.Fix this by following any symlinks, if present.
Quoted 7 lines
After this it works for being invoked through either an alias, symlink, or plain path.
Signed-off-by Geert Uytterhoeven <[email protected]>---
Stack Overflow tells me "readlink -f" is not supported on OS X and some BSDs. Do we care?
I used a similar patch that Greg sent because it used "realpath" instead. It doesn't exist at all on OSX/BSDs, but if they are doing any kernel development at all, they probably know how to install coreutils. I think that's an easier requirement than setting up a GNU-compatible version of readlink.
Best,
-K
Hi Konstantin,
Quoted 15 lines · Konstantin Ryabitsev
Quoted 6 lines · Geert Uytterhoeven
If b4 in your $PATH is a symlink pointing to
b4.sh, $SCRIPT_TOP points to the directory containing the symlink, andb4/command.pycannot be found.Fix this by following any symlinks, if present.
Quoted 7 lines
After this it works for being invoked through either an alias, symlink, or plain path.
Signed-off-by Geert Uytterhoeven <[email protected]>---
Stack Overflow tells me "readlink -f" is not supported on OS X and some BSDs. Do we care?
Quoted 5 lines
I used a similar patch that Greg sent because it used "realpath" instead. It doesn't exist at all on OSX/BSDs, but if they are doing any kernel development at all, they probably know how to install coreutils. I think that's an easier requirement than setting up a GNU-compatible version of readlink.
Greg's version works fine for me, too.
Note that both readlink and realpath are part of coreutils ;-)
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds