tomocafe / bash-boost

bash-boost is a set of library functions for bash, useful for both scripting and interactive use. It draws inspiration from the Boost C++ libraries.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Alternative to "get" value from variable instead of capturing stdout

tomocafe opened this issue · comments

For example, if bb_getx() prints the result to stdout, have bb_getx-v() yield the same result in the variable $BB_RESULT.

my_x="$(bb_getx)"
bb_getx-v
my_x2="$BB_RESULT"
bb_expect "$my_x" "$my_x2" # should be same

Or bb_getx-v VARNAME [getx args ...] to put the value in VARNAME. Use printf -v "$VARNAME" '%s' "$VALUE".