10

The shellscript is very simple:

retroarch $* -c /tmp/retroarch/Data/retroarch/gambatte.cfg

("retroarch" is another shellscript)

If the filename passed contains spaces it fails:

RetroArch [ERROR] :: Could not read ROM file.
1

2 Answers 2

13

Use quotes.

Instead of

yourcommand some file.name

use

yourcommand "some file.name"

When using variables, quote them as well.

yourcommand "$filename"
yourcommand "$@"
...
3
  • 2
    already tried that but did not work!
    – eadmaster
    Commented Jun 28, 2013 at 22:24
  • 1
    Can you please share the internals of your script? You need to take care internally to maintain double quotes throughout given this variable has spaces in it.
    – slm
    Commented Jun 28, 2013 at 22:31
  • oh right, the "retroarch" script was missing double quotes...
    – eadmaster
    Commented Jun 28, 2013 at 22:36
-1

In general you have to either escape the spaces with backslashes () or wrap the path in either single quotes (') or double quotes (").

$ retroarch "$*" -c /tmp/retroarch/Data/retroarch/gambatte.cfg
3
  • already tried that, but i always get the error "Could not read ROM file."
    – eadmaster
    Commented Jun 28, 2013 at 22:29
  • Shouldn't that "$*" be "$@"? Commented Aug 17, 2017 at 11:39
  • @roaima - I kept the example as the OP showed it since my suggestion was around the need to quote it.
    – slm
    Commented Aug 17, 2017 at 12:54

Not the answer you're looking for? Browse other questions tagged .