Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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.
share|improve this question
1  
See mywiki.wooledge.org/Quotes –  jasonwryan Jun 28 '13 at 22:24
add comment

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.

2 Answers

up vote 2 down vote accepted

Use quotes.

Instead of

yourcommand some file.name

use

yourcommand "some file.name"

When using variables, quote them as well.

yourcommand "$filename"
yourcommand "$@"
...
share|improve this answer
    
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
add comment

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
share|improve this answer
    
already tried that, but i always get the error "Could not read ROM file." –  eadmaster Jun 28 '13 at 22:29
add comment

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