Xsession.d errors - how to fix? line... has_option: command not found


Need help to fix that: (updated some files)

/etc/X11/Xsession.d/30x11-common_xresources: line 16: has_option: command not found

# $Id: 30x11-common_xresources 305 2005-07-03 18:51:43Z dnusinow $

# This file is sourced by Xsession(5), not executed.

# If xrdb (from xbase-clients) is installed, merge system-wide X resources.
# Then merge the user's X resources, if the options file is so configured.
if [ -d "$SYSRESOURCES" ] && type xrdb >/dev/null 2>&1; then
  if [ -n "$RESOURCEFILES" ]; then
      xrdb -merge $RESOURCEFILE

if has_option allow-user-resources && [ -f "$USRRESOURCES" ]; then
  if type xrdb >/dev/null 2>&1; then
    xrdb -merge $USRRESOURCES
    # Comment out this command if you desire a legacy-free X environment, and find
    # the warning spurious.
    message "warning: xrdb command not found; X resources not merged."

# vim:set ai et sts=2 sw=2 tw=80:

and this:

/etc/X11/Xsession.d/75dbus_dbus-launch: line 9: has_option: command not found

# $Id:$
# In order to activate the session bus at X session launch
# simply place use-session-dbus into your /etc/X11/Xsession.options file


if has_option use-session-dbus; then
  if [ -z "$DBUS_SESSION_BUS_ADDRESS" ] && [ -x "$DBUSLAUNCH" ]; then

if [ -n "$STARTDBUS" ]; then
  # Note that anything that is D-Bus-activated between here and
  # 95dbus_update-activation-env will not have the complete environment
  # set up by Xsession.d, unless the Xsession.d snippet that sets the
  # environment variable also calls dbus-update-activation-environment.
  # See <https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=815503>
  eval $($DBUSLAUNCH --exit-with-session --sh-syntax)

Hi, @mate2go

From what I've searched, you've "hit" two Bugs that were reported by @Norbert_X in Launchpad, in December 2021, then for the "alpha" version of "Ubuntu MATE 22.04 LTS ("Ubuntu-MATE 22.04 LTS "Jammy Jellyfish" - Alpha amd64"):

  1. Bug #1955135 “multiple issues with /etc/X11/Xsession.d/ - “ "has_option: command not found" : Bugs : xorg package : Ubuntu :


  1. Bug #1955136 “/etc/X11/Xsession.d/75dbus_dbus-launch: line 9: has_option: command not found" ” : Bugs : dbus package : Ubuntu


I've also found that @Norbert_X has posted the following topic, about a month ago (on 22- June-2022), here in the "Ubuntu MATE Community" discussion forums:

In that discussion, Norbert wrote, regarding this issue, the following:

" (...) Three other bugs are 1922414 , 1955135 and 1955136 . They break normal Xsession initialization and fill the ~/.xsession-errors with the following error messages:

/etc/X11/Xsession.d/30x11-common_xresources: line 16: has_option: command not found
/etc/X11/Xsession.d/75dbus_dbus-launch: line 9: has_option: command not found
/etc/X11/Xsession.d/90x11-common_ssh-agent: line 9: has_option: command not found

Local fix for for these 3 bugs can be applied by executing long command below to re-add missing has_option function:

cat <<\EOF | sudo tee /etc/X11/Xsession.d/20x11-add-hasoption
# temporary fix for LP# 1922414, 1955135 and 1955136 bugs
OPTIONS=$(cat "$OPTIONFILE") || true

has_option() {
 if [ "${OPTIONS#*
$1}" != "$OPTIONS" ]; then
   return 0
   return 1

and then reboot. This will allow ssh-agent to start and other necessary fixes.
Note: if you have any additional issues caused by adding above file - please feel free to remove it by sudo rm /etc/X11/Xsession.d/20x11-add-hasoption and inform me about this problem. (...)"

Based on some additional searches that I've done, what seems to me to be the root cause of this issue has been discussed in the following Debian bug, reported about 2 years ago (in June 2020) by Jan Rauberg:

#963059 - x11-common: false linebreak in 20x11-common_process-args function has_option - Debian Bug report logs

... where Jan Rauberg wrote, among other things, the following,:

"(...) * What led up to the situation?
x2go session ignores .Xresource configuration.
There is a false linebreak in function 'has_option' of 20x11-common_process-args.
The lines

 if [ "${OPTIONS#*
$1}" != "$OPTIONS" ]; then

should be

if [ "${OPTIONS#*$1}" != "$OPTIONS" ]; then

Otherwise the function will not be executed and the option 'allow-user-resources'
could not be parsed correctly. As a result the .Xresources-x2go will not be merged in. (...)"

I hope this reply of mine is useful to you (@mate2go) and others :slight_smile: Please note, that I ("ricmarques" = Ricardo Dias Marques) am NOT a Developer of Ubuntu or Ubuntu MATE or Debian. I'm just another Ubuntu MATE user (currently using Ubuntu MATE 20.04 LTS = "Focal Fossa").


thanks @ ricmarques

1 Like