This question already has an answer here:

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.

marked as duplicate by jasonwryan, slm, Hauke Laging, Anthon, manatwork Jun 29 '13 at 14:06

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


Use quotes.

Instead of

yourcommand some file.name


yourcommand "some file.name"

When using variables, quote them as well.

yourcommand "$filename"
yourcommand "$@"
  • 2
    already tried that but did not work! – eadmaster Jun 28 '13 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 Jun 28 '13 at 22:31
  • oh right, the "retroarch" script was missing double quotes... – eadmaster Jun 28 '13 at 22:36

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
  • already tried that, but i always get the error "Could not read ROM file." – eadmaster Jun 28 '13 at 22:29
  • Shouldn't that "$*" be "$@"? – roaima Aug 17 '17 at 11:39
  • @roaima - I kept the example as the OP showed it since my suggestion was around the need to quote it. – slm Aug 17 '17 at 12:54

Not the answer you're looking for? Browse other questions tagged or ask your own question.