4 deleted 3 characters in body
source | link
foo=$(echo "$foo" | sed 's/[\\\/]/\\&/g') # only required if $foo can contain one of \/
set +f     # only required if $foo can containcontains one of \[*?
for i in $(echo "$1" | sed -e "s/bar/$foo/"); do
    echo $i
done
foo=$(echo "$foo" | sed 's/[\\\/]/\\&/g') # only required if $foo can contain one of \/
set +f     # only required if $foo can contain one of \[*?
for i in $(echo "$1" | sed -e "s/bar/$foo/"); do
    echo $i
done
foo=$(echo "$foo" | sed 's/[\\\/]/\\&/g') # only required if $foo can contain one of \/
set +f     # only required if $foo contains one of \[*?
for i in $(echo "$1" | sed -e "s/bar/$foo/"); do
    echo $i
done
3 handle `/\[*?` in $foo; warn about whitespace
source | link
foo=$(echo "$foo" | sed 's/\/[\\\/\\\]/\\&/g') # only required if foo$foo containscan 'contain one of \/'
set +f     # only required if $foo can contain one of \[*?
for i in $(echo $1"$1" | sed -e "s/bar/$foo/"); do
    echo $i
done
foo=$(echo "$foo" | sed 's/\//\\\//g') # only required if foo contains '/'
for i in $(echo $1 | sed -e "s/bar/$foo/"); do
    echo $i
done
foo=$(echo "$foo" | sed 's/[\\\/]/\\&/g') # only required if $foo can contain one of \/
set +f     # only required if $foo can contain one of \[*?
for i in $(echo "$1" | sed -e "s/bar/$foo/"); do
    echo $i
done
2 Handling / in $foo
source | link

eval might be evil, here is a solution avoiding it:

foo=$(echo "$foo" | sed 's/\//\\\//g') # only required if foo contains '/'
for i in $(echo $1 | sed -e "s/bar/$foo/"); do
    echo $i
done

eval might be evil, here is a solution avoiding it:

for i in $(echo $1 | sed -e "s/bar/$foo/"); do
    echo $i
done
foo=$(echo "$foo" | sed 's/\//\\\//g') # only required if foo contains '/'
for i in $(echo $1 | sed -e "s/bar/$foo/"); do
    echo $i
done
1
source | link