[PATCH 1/2] wget: make default timeout configurable, remove a duplicate line

Harald Becker ralda at gmx.de
Sun Oct 20 23:45:47 UTC 2013


Hi Tito !

>> > #!/bin/sh
>> > exec busybox wget -T xxx $@
>> 
>> Also it's better to expand argumanet properly wrt whitespace -
>> use "$@", not $@:
>> 
>> exec busybox wget -T xxx "$@"

Denys, you are right, I missed that topic! Using argument quotes
is my usual style.


>but even using "$@" whitespace in a URL must be correctly
>escaped or it will not work with busybox wget and with real wget.

The reason for this is the point when arguments get expanded or
split into words.


>Busybox wget with wrapper and "$@"  and URL  escaped:
>./wget -c ftp://192.168.1.1/STORE_N_GO/test/Text\ File.txt

Here you pass the wrapper two arguments:
arg[1] = '-c'
arg[2] = 'ftp:.../Text File.txt'

Quoting those arguments in the script wrapper avoids those
arguments being split into three words:

With $@ the wget (program) would receive:
arg[1] = '-T'
arg[2] = 'xxx'
arg[3] = '-c'
arg[4] = 'ftp:.../Text'
arg[5] = 'File.txt'

With "$@" the wget program receive (as expected):
arg[1] = '-T'
arg[2] = 'xxx'
arg[3] = '-c'
arg[4] = 'ftp:.../Text File.txt'


>Busybox wget with wrapper and "$@" and URL not escaped:
>./wget ftp://192.168.1.1/STORE_N_GO/test/Text File.txt

The reason here: The URL is getting split into two arguments by
the *calling* shell. The wrapper receive:

arg[1] = '-c'
arg[2] = 'ftp:.../Text'
arg[3] = 'File.txt'

As the arguments don't contain further characters which require
qouting using $@ gives same results as "$@".

Using "$@" avoids unexpected word splitting when calling
shell/program passes arguments containing space or other special
characters.

--
Harald


More information about the busybox mailing list