Skip to contentSkip to conversation

support/dependencies: add suggested regex to sanitize PATH variable

PATCH In review Colin Foster 2 participants 2 messages Jan 25, 2022 – Jul 26, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 support/dependencies: add suggested regex to sanitize PATH variable

WSL typically has /mnt/c/Program Files/... in the PATH variable. The suggested command will remove anything that has spaces in PATH, which should probably be good enough for most users who see this error.

---
 support/dependencies/dependencies.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
support/dependencies/dependencies.sh +2 -1
index c604a9efcc..e49dfb84a5 100755
@@ -41,7 +41,8 @@ case ":${PATH:-unset}:" in
 (*" "*|*"${TAB}"*|*"${NL}"*)
 	printf "\n"
 	printf "Your PATH contains spaces, TABs, and/or newline (\\\n) characters.\n"
-	printf "This doesn't work. Fix you PATH.\n"
+	printf "This doesn't work. Fix your PATH. You can try running:\n"
+	printf "export PATH=\$(echo \$PATH | grep -Po \"(?::|^)[^\ :]+(?=(?::|$))\" | tr -d '\\\n'; echo)\n"
 	exit 1
 	;;
 esac
Signature · 6 lines
2.25.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw

Colin, All,

Sorry for the long delay in reviewing this change...

On 2022-01-25 11:07 -0800, Colin Foster spake thusly:

Quoted 3 lines

WSL typically has /mnt/c/Program Files/... in the PATH variable. The suggested command will remove anything that has spaces in PATH, which should probably be good enough for most users who see this error.

We have many other sanity checks, like current directory in PATH or LD_LIBRARYPATH, or Perl stuff, and so on, and we do not explain for each of them how to solve the problem. Especially, the space-in-PATH is relatively easy to fix.

We assume that the user is knowledgeable enough to fix those on their own.

Regards,
Yann E. MORIN.

Quoted 26 lines
---
 support/dependencies/dependencies.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
support/dependencies/dependencies.sh +2 -1
index c604a9efcc..e49dfb84a5 100755
@@ -41,7 +41,8 @@ case ":${PATH:-unset}:" in
 (*" "*|*"${TAB}"*|*"${NL}"*)
 	printf "\n"
 	printf "Your PATH contains spaces, TABs, and/or newline (\\\n) characters.\n"
-	printf "This doesn't work. Fix you PATH.\n"
+	printf "This doesn't work. Fix your PATH. You can try running:\n"
+	printf "export PATH=\$(echo \$PATH | grep -Po \"(?::|^)[^\ :]+(?=(?::|$))\" | tr -d '\\\n'; echo)\n"
 	exit 1
 	;;
 esac
Signature · 6 lines
2.25.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Signature · 10 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot