Skip to content
This repository has been archived by the owner on Mar 3, 2023. It is now read-only.

[WSL] expr: syntax error: missing argument after ‘8’ #23733

Open
1 task
lfarinaa opened this issue Mar 21, 2022 · 3 comments
Open
1 task

[WSL] expr: syntax error: missing argument after ‘8’ #23733

lfarinaa opened this issue Mar 21, 2022 · 3 comments

Comments

@lfarinaa
Copy link

lfarinaa commented Mar 21, 2022

Prerequisites

Description

Every time you run atom, it returns an error message (it's the cinnamon thing from the last update)

Steps to Reproduce

  1. unset DESKTOP_SESSION
  2. run atom (namely /usr/bin/atom)

Expected behavior:

Atom opens

Actual behavior:

returns "expr: syntax error: missing argument after ‘8’"
Atom opens

Reproduces how often:

Always

Versions

Atom : 1.60.0
Electron: 9.4.4
Chrome : 83.0.4103.122
Node : 12.14.1
OS: Ubuntu on WSL (it's normal to run without a desktop)

Additional Information

Can be fixed trivially by changing lines 172-174 to check that DESKTOP_SESSION is indeed set. E.g.:
if [[ -v DESKTOP_SESSION ]]; then
if [[ "$(expr substr $(printenv | grep "DESKTOP_SESSION=") 17 8)" == "cinnamon" ]]; then
cp "resources/linux/desktopenviroment/cinnamon/atom.nemo_action" "/usr/share/nemo/actions/atom.nemo_action"
fi
fi

@dr1ver1
Copy link

dr1ver1 commented Mar 24, 2022

Same issue experienced on "pure" Ubuntu (i.e. not running under WSL).
DESKTOP_SESSION=ubuntu
Error message isn't generated consistently. I suspect it is being generated when I use sudo atom --no-sandbox ...

@MatthewSchultz
Copy link

I see this error as well, but atom still runs, and runs fine.

@ptous
Copy link

ptous commented Apr 10, 2022

This seems to be an issue with quoting on line 172 of the atom shell script, which is installed as /usr/bin/atom.

  if [[ "$(expr substr $(printenv | grep "DESKTOP_SESSION=") 17 8) == "cinnamon" ]]; then
    cp "resources/linux/desktopenviroment/cinnamon/atom.nemo_action" "/usr/share/nemo/actions/atom.nemo_action"
  fi

When printenv | grep "DESKTOP_SESSION=" is an empty string, because it is unquoted, it disappears from the argument list of expr substr, which requires three arguments.

This is fixed by quoting the inner $() expression like so.

  if [[ "$(expr substr "$(printenv | grep "DESKTOP_SESSION=")" 17 8)" == "cinnamon" ]]; then
    cp "resources/linux/desktopenviroment/cinnamon/atom.nemo_action" "/usr/share/nemo/actions/atom.nemo_action"
  fi

Oops, missed that this was already mentioned.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants