Linux maintainer tooling and workflows
 help / color / mirror / Atom feed
* [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

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