"Robert Anderson" <[EMAIL PROTECTED]> writes: > substvar=$( echo @var@ | sed -e "s,@var@,`_quote_for_sed $var`," )
Unfortunately this won't work for implementations of 'echo' that treat backslash specially. POSIX 1003.1-2001 requires such behavior, and it is common. I've heard that this requirement will be changed soon, but nevertheless we need to port to hosts that implement it. Also, it won't work if @var@ is -n, on implementations where "echo -n" echoes without a trailing newline. One workaround is to use printf if available, and fall back on echo if printf is not available. Another possibility is to use expr, though this will require a loop. But these will be portability hassles in their own right. Perhaps it'd be simpler just to pick some other delimiter like '|' and live with its limitations.
