diff mbox series

support/dependencies: add suggested regex to sanitize PATH variable

Message ID 20220125190714.30785-1-colin.foster@in-advantage.com
State Rejected
Headers show
Series support/dependencies: add suggested regex to sanitize PATH variable | expand

Commit Message

Colin Foster Jan. 25, 2022, 7:07 p.m. UTC
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.

Signed-off-by: Colin Foster <colin.foster@in-advantage.com>
---
 support/dependencies/dependencies.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Yann E. MORIN July 26, 2022, 9:30 a.m. UTC | #1
Colin, All,

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

On 2022-01-25 11:07 -0800, Colin Foster spake thusly:
> 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.

> Signed-off-by: Colin Foster <colin.foster@in-advantage.com>
> ---
>  support/dependencies/dependencies.sh | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/support/dependencies/dependencies.sh b/support/dependencies/dependencies.sh
> index c604a9efcc..e49dfb84a5 100755
> --- a/support/dependencies/dependencies.sh
> +++ b/support/dependencies/dependencies.sh
> @@ -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
> -- 
> 2.25.1
> 
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot
diff mbox series

Patch

diff --git a/support/dependencies/dependencies.sh b/support/dependencies/dependencies.sh
index c604a9efcc..e49dfb84a5 100755
--- a/support/dependencies/dependencies.sh
+++ b/support/dependencies/dependencies.sh
@@ -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