Bash script argument with spaces

I'm trying to use a Torrent-Video-Player script, but it doesn't work with files that contain spaces. This is a Nautilus script.

#!/bin/bash
xterm -e "peerflix "$1" --vlc"

      

"test.torrent" → OK
"test test.torrent" → Unable to test execvp peerflix: no such file or directory found

0


source to share


1 answer


Change the line

xterm -e "peerflix "$1" --vlc"

      

to

xterm -e "peerflix '$1' --vlc"

      

or



xterm -e "peerflix \"$1\" --vlc"

      

The first form is equivalent:

xterm -e "peerflix " $1 " --vlc"

      

This is not what you expected.

+3


source







All Articles