Chinaunix首页 | 论坛 | 博客
  • 博客访问: 308006
  • 博文数量: 47
  • 博客积分: 2455
  • 博客等级: 大尉
  • 技术积分: 558
  • 用 户 组: 普通用户
  • 注册时间: 2008-12-25 15:43
文章分类

全部博文(47)

文章存档

2016年(2)

2012年(10)

2011年(13)

2010年(1)

2009年(19)

2008年(2)

分类: LINUX

2010-03-19 16:50:13

Cygwin Doesn't Register All Environment Variables When Using SSH

When initiating a Cygwin bash session via SSH, Cygwin only registers the environment variables for the SYSTEM account, not for the individual user's account.

So I added the following code to the end of my .bashrc file:

if [ "$SSH_TTY" ]; then
pushd . >/dev/null
for __dir in \
/proc/registry/HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Control/Session\ Manager/Environment \
/proc/registry/HKEY_CURRENT_USER/Environment
do
cd "$__dir"
for __var in *
do
__var=`echo $__var | tr '[a-z]' '[A-Z]'`
test -z "${!__var}" && export $__var="`cat $__var`" >/dev/null 2>&1
done
done
unset __dir
unset __var
popd >/dev/null
fi

To apply this fix for all users, add it to /etc/profile instead.

Please note, this doesn't correctly register environment variable names that are illegal in Cygwin, such as those that contain a period.

阅读(1475) | 评论(0) | 转发(0) |
0

上一篇:fncache in mercurial

下一篇:QNX启动ssh server

给主人留下些什么吧!~~