Bash
為什麼我在 Swan-Cygwin 中收到此錯誤?
我正在使用Swan在我的 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-common: https://ghostbin.com/paste/7bn7x
startxfce4: https://ghostbin.com/paste/zfxoe
/etc/xdg/xfce4/xinitrc: https://ghostbin.com/paste/uw4tq
.bashrc :https ://ghostbin.com/paste/4ojjj
正如您所懷疑的那樣,每次打開新外殼時執行的腳本之一似乎都會對您的 $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" 是一個字元串