On 10/16/2012 12:08 AM, Greg Wooledge wrote:
Sidestepping the direct question for a moment, you could use a temporary
file instead of a command substitution to store the output. Then there
would be no subshell involved.
Thanks, Greg. I don't like creating temporary files unnecessarily, so I went
the route of using SHELLOPTS value instead and massaging it into a set of
"set" calls on restore. Like this:
declare -r shellopts="$1"
declare -r on_pattern="^(${shellopts//:/|})\$"
declare attr
for attr in `set -o | awk '{print \$1}'`; do
if [[ $attr =~ $on_pattern ]]; then
set -o $attr
else
set +o $attr
fi
done
Might need to do something with that awk invocation, though.
Sincerely,
Nick