Your echo is redundant. Just quote the expansion and assign it.
NAK. Try this: MODULES=( '!foo' '!bar' ) modules="${MODULES[@]/#\!*}" [[ $modules ]] && echo "'$modules' is not a null string" ' ' is not a null string
modules="${MODULES[@]/#\!*}"
I think we're a looooong way away from the day when there's a '!' as part of a module name, but I think it's probably best to anchor the expression to the start of each element regardless.
OK, but the quotes aren't needed because word splitting is not performed here. So we finally get:
modules=$( echo ${MODULES[@]/#\!*} )
-- Kurt
We're going to have to agree that we're both right, and we're both wrong. The echo is _still_ unnecessary. I've learned to quote everything in bash, and now it's working against me. $ MODULES=( '!foo' '!bar' ) $ modules=${MODULES[@]/#\!*/} $ [[ -z $modules ]] && echo null null d