#!/bin/bash

COMMAND=“builddir_impl”

# Script from: # stackoverflow.com/questions/11027679/bash-store-stdout-and-stderr-in-different-variables unset t_std t_err t_ret eval “$( $COMMAND $@ 2> >(t_err=”$(cat)“; typeset -p t_err) > >(t_std=”$(cat)“; typeset -p t_std); t_ret=$?; typeset -p t_ret )”

# print the stderr stream of the command echo “${t_err}”

# change directory if there is no error if [ $t_ret -eq 0 ]; then

cd "${t_std}"

fi

# set the retun code (exit $t_ret)