为什么我在 Swan-Cygwin 中收到此错误?

为什么我在 Swan-Cygwin 中收到此错误?

我在用天鹅在我的 Windows 计算机上提供 Linux 支持,

我在打开“Swan Terminal”(Xfce4/bash)时遇到了一个小问题。

它在启动时出现以下错误:

-bash: [: /home/Michael: binary operator expected
-bash: [: /home/Michael: binary operator expected
-bash: [: /home/Michael: binary operator expected
-bash: [: /home/Michael: binary operator expected
-bash: [: /home/Michael: binary operator expected
-bash: [: /home/Michael: binary operator expected
-bash: [: /home/Michael: binary operator expected
-bash: [: /home/Michael: binary operator expected
-bash: [: /home/Michael: binary operator expected
-bash: [: /home/Michael: binary operator expected
-bash: [: /home/Michael: binary operator expected
-bash: [: /home/Michael: binary operator expected
-bash: [: /home/Michael: binary operator expected
-bash: [: /home/Michael: binary operator expected
-bash: [: /home/Michael: binary operator expected
-bash: [: /home/Michael: binary operator expected
-bash: [: /home/Michael: binary operator expected
-bash: [: /home/Michael: binary operator expected

我有理由相信这可能是由于我的帐户名(“Michael Wilcox”)之间有空格造成的。

Swan 上我的主文件夹的当前路径:

C:\Users\Michael Wilcox\AppData\Roaming\Swan

天鹅安装:

C:\ProgramData\Swan

有谁知道如何解决这一问题?

更新:仔细一看,.xsessions-errors 内容如下:

/etc/X11/xinit/xinitrc-common: line 20: [: /home/Michael: binary operator expected
/usr/bin/startxfce4: line 111: [: /home/Michael: binary operator expected
/usr/bin/startxfce4: line 113: [: /home/Michael: binary operator expected
/etc/xdg/xfce4/xinitrc: line 67: test: /home/Michael: binary operator expected
/etc/xdg/xfce4/xinitrc: line 88: test: /home/Michael: binary operator expected

xinitrc-常见:https://ghostbin.com/paste/7bn7x
启动xfce4:https://ghostbin.com/paste/zfxoe
/etc/xdg/xfce4/xinitrc:https://ghostbin.com/paste/uw4tq
.bashrc:https://ghostbin.com/paste/4ojjj

答案1

正如您所怀疑的,似乎每次打开新 shell 时运行的脚本之一都会在 $HOME 上执行一个查询,该查询包含空格,这是不好的。

xinitrc-common - 包含以下行:

[ -r $HOME/.profile ] && . $HOME/.profile

startxfce4 - 包含以下几行:

if test "x$XDG_CONFIG_HOME" = "x" 
then 
  BASEDIR="$HOME/.config/xfce4/" 
else 
  BASEDIR="$XDG_CONFIG_HOME/xfce4" fi

/etc/xdg/xfce4/xinitrc - 包含以下行:

if test "x$XDG_CONFIG_HOME" = "x" ; then 
  XDG_CONFIG_HOME=$HOME/.config 
fi 
[ -d "$XDG_CONFIG_HOME" ] || mkdir "$XDG_CONFIG_HOME"

您应该在这些位置引用 $HOME 相关参数作为包含空格的路径。

您应该引用这些参数。

例如更改$HOME为:"$HOME"

使用 "" 将使 shell 识别出 "C:\Users\Michael Wilcox\" 是一个字符串

答案2

xinitrc-common双引号扩展$HOME就行

[ -r $HOME/.profile ] && . $HOME/.profile

或紧随其后的几行,但应该如此。

同样,startxfce4包含对 的未加引号的引用$HOME,文件也是如此xinitrc

您必须修改它们,以便它们在$HOME变量扩展(以及其值源自 的任何变量的扩展$HOME)周围使用双引号。

理想情况下,如果您有能力这样做,这些相当于错误的事情应该报告给相关软件的上游维护人员。

相关内容