Consider the following example of sed with shell expansion:
sed -i "s/FOO/$BAR/g" /etc/baz.conf
That would fail if
$BAR contains a path with slashes (
/) - the shell paramter expansion would add these slashes to the sed expression and make it invalid.
Instead of escaping the contents of
$BAR in these cases, we can actually use another separator instead of
sed -i "s~FOO~$BAR~g" /etc/baz.conf
Of course, that doesn’t solve all theoretical problems with the sed separators, but helps a lot if the contents of
$BAR are predictable.