What I want to do: Start my script with a list of files as arguments. From within my script I want to start xterm that starts mplayer with these files.
I tried several things. I call my script like this:
myscript.sh *
The files are named like
"aaa AAA"
"bbb BBB"
"ccc DDD"
(i.e. filenames with spaces) and are playable sounds, music or videos with mplayer.
This is what I tried
All of the following commands were written inside my script!
I tried:
The following works. Files are printed.
ls -l $@The following works. Files are printed.
IFS='\n' ls -l $*The following works. Files are printed. Strangely I do not need the
IFS='\n'here. Why?xterm -e 'ls -l $*; read'This does not find the files.
FILES=$@ ls -l $FILESThis does not find the files. Here all filenames are treated as one long filename. (???)
IFS='\n' FILES=$@ ls -l $FILESThis does not find the files.
export FILES=$@ ls -l $FILESBut the following works. Files are printed.
IFS='\n' export FILES=$@ ls -l $FILES
Now with mplayer.
This works.
IFS='\n' export FILES=$@ mplayer $FILESThis does not work. But why does number 2 for
ls -lwork then? Here mplayer exits printing it’s help as if I just startmplayerwith no arguments.xterm -e 'mplayer $*; read'This does not work. It fails for all the files with spaces in the filename.
IFS='\n' FILES=$@ xterm -e 'mplayer $FILES; read'
Question: How can I start mplayer from its own xterm with the files saved in the $FILES variable?