| Summary: | [shell] return values with spaces are not escaped correctly | ||
|---|---|---|---|
| Product: | Busybox | Reporter: | Andy B <ab> |
| Component: | Standard Compliance | Assignee: | unassigned |
| Status: | RESOLVED INVALID | ||
| Severity: | normal | CC: | busybox-cvs |
| Priority: | P3 | ||
| Version: | 1.15.x | ||
| Target Milestone: | --- | ||
| Hardware: | Other | ||
| OS: | Linux | ||
| Host: | Target: | ||
| Build: | |||
|
Description
Andy B
2009-10-27 17:43:15 UTC
Which shell you are testing, ash or hush?
> incorrect - e.g. #1:
> # for i in `find .`
Did you try it in bash? It also "fails" there. This is just how it should work in this case.
You can use:
for i in "`find .`"
but this will jam *all* filenames into one $i. So probably:
find . | while read filename; do ...; done
Try this script:
#!/bin/sh
testing() {
echo "Testing $1"
rm -rf dir 2>/dev/null
mkdir dir
>"dir/a b"
echo "Test with find"
$1 -c 'for i in `find dir`; do echo $i; done'
echo "Test with ls"
$1 -c 'for i in `ls dir/a*`; do echo $i; done'
echo
}
testing "bash"
testing "./busybox ash"
testing "./busybox hush"
It outputs:
Testing bash
Test with find
dir
dir/a
b
Test with ls
dir/a
b
Testing ./busybox ash
Test with find
dir
dir/a
b
Test with ls
dir/a
b
Testing ./busybox hush
Test with find
dir
dir/a
b
Test with ls
dir/a
b
as you see, both busybox shells are compatible with bash in this regard.
|