Le 26/01/2011 03:10, Rafael Kitover a écrit :
On 1/25/2011 7:14 PM, Cyrille Lefevre wrote:
v2$ uname -a
CYGWIN_NT-5.1 PC213736 1.7.7(0.230/5/3) 2010-08-31 09:58 i686 Cygwin
aka
Windows XP Professional Ver 5.1 Build 2600 Service Pack 3
though SSH at least :
v2$ regtool get /machine/SYSTEM/CurrentControlSet/Control/Session\
Manager/Environment/PATH
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\orawin\BIN;C:\Program
Files\ATI Technologies\ATI Control Panel;"C:\Program
Files\Hummingbird\Connectivity\7.00\Accessories\";C:\Program
Files\QuickTime\QTSystem\;D:\sfu\Perl\bin\;D:\sfu\common\;C:\WINDOWS\system32\WindowsPowerShell\v1.0\;C:\Program
Files\Samsung\Samsung PC Studio 3\
gives :
/usr/local/bin:/usr/bin:/bin:/cygdrive/c/WINDOWS/system32:/cygdrive/c/WINDOWS:/cygdrive/c/WINDOWS/System32/Wbem:/cygdrive/c/orawin/BIN:/cygdrive/c/Program
Files/ATI Technologies/ATI Control Panel:"C:/Program
Files/Hummingbird/Connectivity/7.00/Accessories/":/cygdrive/c/Program
Files/QuickTime/QTSystem/:/cygdrive/d/sfu/Perl/bin/:/cygdrive/d/sfu/common/:/cygdrive/c/WINDOWS/system32/WindowsPowerShell/v1.0/:/cygdrive/c/Program
Files/Samsung/Samsung PC Studio 3/:/bin
note the unconverted path between double-quotes :
"C:/Program Files/Hummingbird/Connectivity/7.00/Accessories/"
I saw this problem on msys, I think it applies to cygwin as well.
If you just go into environment under advanced system settings in
control panel and remove the double quotes, it will work correctly. I'm
on Windows 7.
don't be kidding ! ok, I'm joking...
I'm reporting a cygwin bug...
of course I know I could edit the windows environment variables.
however, this problem has to be fixed.
also, how about to get rid of final slashes (.../ => ...) ?
You could reprocess your PATH in your .bashrc, but the final slashes
should have no effect on how the PATH is actually used...
everything is possible at shell level, even more efficiently, but since
the path is working by the cygwin layer, why not to clean things up.
PS : no fork cleanups...
# space tab newline
_IFS=${IFS:-'
'}
IFS=':'
# clean up final /'es
_PATH= _sep=
for _path in $PATH; do
case $path in */) _path=${_path#/} ;; esac
_PATH=${_PATH}${_sep}${_path}
_sep=':'
done
PATH=${_PATH}
# cleanup twins
_PATH= _sep=
for _path in $PATH; do
case ":${_PATH}:" in
*":${_path}:"*) ;;
*) _PATH=${_PATH}${_sep}${_path}; _sep=':' ;;
esac
done
PATH=${_PATH}
# not necessary, but...
# cleanup windows paths w/ space
_PATH= _sep=
for _path in $PATH; do
case ":${_path}:" in
*' '*) ;;
*) _PATH=${_PATH}${_sep}${_path}; _sep=':' ;;
esac
done
PATH=${_PATH}
IFS=${_IFS}
unset _IFS _PATH _path _sep
untested but should work...
of course, you may do this in one loop only !
also, I reworked my version of ssh-session-env.sh
Regards,
Cyrille Lefevre
--
mailto:cyrille.lefevre-li...@laposte.net
#!/bin/sh
#
# ssh-session-env.sh - script for installation in /etc/profile.d
#
# because in sessions started from sshd the windows system environment
# variables in general are not set except for some which are possible
# special handled (like PATH, etc.) and the windows user environment
# variables are not set from the actual user but from the user of the
# sshd server this script is used to build this environment settings in
# shells with bournish syntax which uses /etc/profile for initialization.
#
# authors: Kurt Franke, Cyrille Lefevre
#
# date: 26 january 2011
if ps -fp ${PPID} | grep -q "/usr/sbin/sshd$"; then
_SECONDS_=${SECONDS:-$(date +%s)}
_IFS_=${IFS}
IFS='
'
eval "$( (
regtool -qv list /machine/SYSTEM/CurrentControlSet/Control/Session\
Manager/Environment
regtool -qv list /user/Environment
regtool -qv list /user/Volatile\ Environment
) |
awk -v q="'" -v mp="$(mount --show-cygdrive-prefix)" '
function s2a(str, a, sep, i, t) {
if (sep == "") sep = " +"
split(str, t, sep)
for (i in t) a[t[i]] = ""
}
function uniqp(p, i, j, k, o, n, a, s) {
k = split(p, o, ":")
for (i = j = 1; i <= k; i++)
if (!(tolower(o[i]) in a))
a[tolower(n[j++] = o[i])] = ""
p = s = ""
for (i = 1; i < j; i++) {
p = p s n[i]
s = ":"
}
return p
}
BEGIN {
s2a("APPDATA CLASSPATH QTJAVA LOCALAPPDATA USERPROFILE VS90COMNTOOLS", \
noconvert)
s2a("HOMEPATH PATH TEMP TMP", override)
sub(/.*\n/, "", mp)
sub(/[ \t].*/, "", mp)
}
! /\\ \(\)$/ {
var = toupper($1)
$1 = $2 = $3 = ""
sub("^ +", "")
environ[var] = var == "PATH" && var in environ ? \
environ[var] ";" $0 : $0
}
END {
flag = 1
while (flag) {
flag = 0
for (var in environ) {
val = environ[var]
if (match(val,/%[^%]+%/)) {
flag = 1
subvar = substr(val, RSTART+1, RLENGTH-2)
subvar = toupper(subvar)
subval = subvar in environ ? \
environ[subvar] : ENVIRON[subvar]
if (subval !~ /%[^%]%/) {
head = substr(val, 1, RSTART-1)
tail = substr(val, RSTART+RLENGTH)
environ[var] = head subval tail
}
}
}
}
for (var in environ) {
if (!(var in override) && var in ENVIRON)
continue
val = environ[var]
if (!(var in noconvert) && (val ~ /;/ || val ~ /^"?.:/)) {
gsub(/([a-zA-Z]):/, mp "/&", val)
gsub(/\\/,"/",val)
gsub(/[:"]|\/$/,"",val)
gsub(/\/?;/,":",val)
}
if (var == "PATH") {
gsub(/"([a-zA-Z]):/, mp "/&", ENVIRON[var])
gsub(/"|\/$/,"",ENVIRON[var])
gsub(/\/:/,":",ENVIRON[var])
val = uniqp(ENVIRON[var] ":" val)
}
gsub(q, "\\"q, val)
print "export", var "="q val q
}
}
')"
echo "elapsed: $(( ${SECONDS:-$(date +%s)} - $_SECONDS_ ))s"
IFS=${_IFS_}
unset _IFS_ _SECONDS_
fi
# eof
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple