* [PATCH] Fix invocation of b4.sh through a symlink
@ 2020-03-24 9:00 Geert Uytterhoeven
2020-03-24 14:33 ` Konstantin Ryabitsev
0 siblings, 1 reply; 3+ messages in thread
From: Geert Uytterhoeven @ 2020-03-24 9:00 UTC (permalink / raw)
To: Konstantin Ryabitsev; +Cc: tools, Geert Uytterhoeven
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.
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
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(-)
diff --git a/b4.sh b/b4.sh
index cafeee186115832d..e5459192d978e41b 100755
--- a/b4.sh
+++ b/b4.sh
@@ -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" "${@}"
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] Fix invocation of b4.sh through a symlink
2020-03-24 9:00 [PATCH] Fix invocation of b4.sh through a symlink Geert Uytterhoeven
@ 2020-03-24 14:33 ` Konstantin Ryabitsev
2020-03-24 15:12 ` Geert Uytterhoeven
0 siblings, 1 reply; 3+ messages in thread
From: Konstantin Ryabitsev @ 2020-03-24 14:33 UTC (permalink / raw)
To: Geert Uytterhoeven; +Cc: tools
On Tue, Mar 24, 2020 at 10:00:57AM +0100, Geert Uytterhoeven wrote:
> 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.
>
> Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
> ---
> 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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Fix invocation of b4.sh through a symlink
2020-03-24 14:33 ` Konstantin Ryabitsev
@ 2020-03-24 15:12 ` Geert Uytterhoeven
0 siblings, 0 replies; 3+ messages in thread
From: Geert Uytterhoeven @ 2020-03-24 15:12 UTC (permalink / raw)
To: Konstantin Ryabitsev; +Cc: tools
Hi Konstantin,
On Tue, Mar 24, 2020 at 3:33 PM Konstantin Ryabitsev
<konstantin@linuxfoundation.org> wrote:
> On Tue, Mar 24, 2020 at 10:00:57AM +0100, Geert Uytterhoeven wrote:
> > 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.
> >
> > Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
> > ---
> > 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.
Greg's version works fine for me, too.
Note that both readlink and realpath are part of coreutils ;-)
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-03-24 15:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-24 9:00 [PATCH] Fix invocation of b4.sh through a symlink Geert Uytterhoeven
2020-03-24 14:33 ` Konstantin Ryabitsev
2020-03-24 15:12 ` Geert Uytterhoeven
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).