Preserving Blanks in Parameters to Shell Script
Shlomi Fish
shlomif at iglu.org.il
Mon Jun 14 16:40:19 IDT 2010
On Monday 14 Jun 2010 15:27:43 Aharon Schkolnik wrote:
> Hi.
>
> I want to write a script which will nice ffmpeg whatever parameters it is
> given - ie:
>
> #!/bin/sh
>
> nice ffmpeg $*
>
> #
>
>
> However, what if I have a file named `file one'
>
>
> I would like to type `myscript -i file\ one output.whatever`
>
> I do not want to change what I type - the script needs to be a drop-in
> replacement for the ffmpeg command.
>
>
> Is there any way to do make the script preserve the backslashed space ?
>
Yes, use quotes:
[shell] # Untested
#!/bin/sh
nice ffmpeg "$@"
[/shell]
"$@" when in quotes causes it to be something like "$1" "$2" "$3" "$4" , and
so forth up to the number of quotes.
The whitespace-in-shell-variables-handling is part of a general code/markup
injection problem:
* http://community.livejournal.com/shlomif_tech/35301.html
* http://community.livejournal.com/shlomif_tech/14671.html
Regards,
Shlomi Fish
--
-----------------------------------------------------------------
Shlomi Fish http://www.shlomifish.org/
My Aphorisms - http://www.shlomifish.org/humour.html
God considered inflicting XSLT as the tenth plague of Egypt, but then
decided against it because he thought it would be too evil.
Please reply to list if it's a mailing list post - http://shlom.in/reply .
More information about the Linux-il
mailing list