Search code examples
linuxbashxorgarchxrdp

Getting a "-bash: [: : integer expression expected" error on bash shell startup in arch


Anytime I startup my bash shell I'm getting this pervasive "-bash: [: : integer expression expected" error, which leads me to my .xinitrc, .bashrc, and .bash_profile. I just chaged my /etc/X11/xinit/xinitrc before this started happening, which leads me to believe it's related, but I'm stumped.

I was in the process of setting up xrdp, which might be a factor.

~/.xinitrc

#!/bin/sh

userresources=$HOME/.Xresources
usermodmap=$HOME/.Xmodmap
sysresources=/etc/X11/xinit/.Xresources
sysmodmap=/etc/X11/xinit/.Xmodmap

# merge in defaults and keymaps

if [ -f $sysresources ]; then







    xrdb -merge $sysresources

fi

if [ -f $sysmodmap ]; then
    xmodmap $sysmodmap
fi

if [ -f "$userresources" ]; then







    xrdb -merge "$userresources"

fi

if [ -f "$usermodmap" ]; then
    xmodmap "$usermodmap"
fi

# start some nice programs

if [ -d /etc/X11/xinit/xinitrc.d ] ; then
 for f in /etc/X11/xinit/xinitrc.d/?*.sh ; do
  [ -x "$f" ] && . "$f"
 done
 unset f
fi

exec i3
#exec sh /home/username/.screenlayout/display.sh

~/.bashrc

#
# ~/.bashrc
#

# If not running interactively, don't do anything
[[ $- != *i* ]] && return

alias ls='ls --color=auto'
PS1='[\u@\h \W]\$ '
alias i3-config='vim .config/i3/config'
alias polybar-config='vim .config/polybar/config'
alias wallpaper='feh --bg-fill --randomize /home/username/Pictures/Wallpapers/'
export CHROME_EXECUTABLE='google-chrome-stable'
export JAVA_HOME='/usr/lib/jvm/java-8-openjdk'
export ANDROID_SDK_ROOT=$HOME/android-sdk
export PATH=$PATH:/opt/flutter/bin
export PATH=$JAVA_HOME/bin:$PATH
export PATH=$PATH:$ANDROID_SDK_ROOT/platform-tools/
export PATH=$PATH:$ANDROID_SDK_ROOT/tools/bin/
export PATH=$PATH:$ANDROID_SDK_ROOT/tools/emulator
export PATH=$PATH:$ANDROID_SDK_ROOT/tools/
export PATH=$PATH:`pwd`/flutter/bin
export PATH=$PATH:$HOME/.pub-cache/bin
source /usr/share/nvm/init-nvm.sh
export GITLAB_API_TOKEN='blahblahblah'
export NPM_TOKEN='blahblahblah'
alias tailscale-torrent='sudo tailscale up --exit-node=xxx --exit-node-allow-lan-access=false'
alias tailscale-normal='sudo tailscale up --exit-node= --reset'
alias dvorak='setxkbmap us dvorak'
alias us='setxkbmap us'
alias pia-client='/opt/piavpn/bin/pia-client'
alias vmware-background='sudo vmware &'

umask 002
export SYSTEMD_EDITOR=vim

~/.bash_profile

#
# ~/.bash_profile
#

[[ -f ~/.bashrc ]] && . ~/.bashrc

if [ -z "${DISPLAY}" ] && [ "${XDG_VTNR}" -eq 1 ]; then
        exec startx
fi

/etc/X11/xinit/xinitrc

#!/bin/sh

userresources=$HOME/.Xresources
usermodmap=$HOME/.Xmodmap
sysresources=/etc/X11/xinit/.Xresources
sysmodmap=/etc/X11/xinit/.Xmodmap

# merge in defaults and keymaps

if [ -f $sysresources ]; then







    xrdb -merge $sysresources

fi

if [ -f $sysmodmap ]; then
    xmodmap $sysmodmap
fi

if [ -f "$userresources" ]; then







    xrdb -merge "$userresources"

fi

if [ -f "$usermodmap" ]; then
    xmodmap "$usermodmap"
fi

# start some nice programs

if [ -d /etc/X11/xinit/xinitrc.d ] ; then
 for f in /etc/X11/xinit/xinitrc.d/?*.sh ; do
  [ -x "$f" ] && . "$f"
 done
 unset f
fi


twm &
xclock -geometry 50x50-1+1 &
xterm -geometry 80x50+494+51 &
xterm -geometry 80x20+494-0 &
exec xterm -geometry 80x66+0+0 -name login

I've tried cleaning up my bashrc and bash_profile with no luck


Solution

  • Replace [ "${XDG_VTNR}" -eq 1 ] in your .bash_profile with [ "${XDG_VTNR}" = 1 ] so your .bash_profile looks like this:

    # ~/.bash_profile
    #
    
    [[ -f ~/.bashrc ]] && . ~/.bashrc
    
    if [ -z "${DISPLAY}" ] && [ "${XDG_VTNR}" = 1 ]; then
            exec startx
    fi
    

    That should remove the error in the case that $XDG_VTNR is not set or not a number.

    For consistency in the usage of [ or [[ you may also want to change the line above, so your .bash_profile would look like this:

    # ~/.bash_profile
    #
    
    [ -f ~/.bashrc ] && . ~/.bashrc
    
    if [ -z "${DISPLAY}" ] && [ "${XDG_VTNR}" = 1 ]; then
            exec startx
    fi
    

    But that's a matter of taste.