hosh icon indicating copy to clipboard operation
hosh copied to clipboard

withWorkingDir built-in

Open dfa1 opened this issue 6 years ago • 0 comments

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.

dfa1 avatar Jun 05 '19 09:06 dfa1