hosh
hosh copied to clipboard
withWorkingDir built-in
Problem Often in bash scripts I use this pattern:
DIR=build
rm -rf $DIR
mkdir -p $DIR
# use $DIR
to make sure that $DIR is an empty directory before using it.
Solution
introduce a new wrapper to be able to express same pattern, in a more intention revealing way:
withWorkingDir ${DIR} { }
that also cd into ${DIR}.
Benefit To me advantage is clear but let's wait for some external input.