From eb648717f20ad28d54ae0d3795346980a9f039f4 Mon Sep 17 00:00:00 2001 From: John Stevenson Date: Wed, 24 Oct 2012 15:19:16 +0200 Subject: [PATCH] Improve Cygwin path-stripping code Using awk to strip the Cygwin paths creates a null-byte at the end of the string. This makes the last item in the path unresolvable and causes child processes that are not dependent on msys-1.0.dll to inherit POSIX rather than Windows paths. This routine avoids awk and includes code from nicerobot on StackOverflow: http://stackoverflow.com/a/370255/1127485 Signed-off-by: johnstevenson --- etc/profile | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/etc/profile b/etc/profile index 1f3a001b..4d48194f 100644 --- a/etc/profile +++ b/etc/profile @@ -24,10 +24,8 @@ fi # strip out cygwin paths from PATH case "$PATH" in */cygwin/*) - PATH="$(awk -vRS=: -vORS=: '!/cygwin/' <<< "$PATH")" - # awk always adds a trailing separator - export PATH="${PATH%:}" - ;; + export PATH=$(IFS=':'; t=($PATH); unset IFS; t=(${t[@]%%*/cygwin/*}); IFS=':'; echo "${t[*]}") + ;; esac if [ -z "$USERNAME" ]; then -- 2.11.4.GIT