optparse icon indicating copy to clipboard operation
optparse copied to clipboard

Tempfile-free evaluation by `optparse.compose` (fullly backward-compatible)

Open ShamrockLee opened this issue 4 years ago • 0 comments

The previous API requires a temporary file to be created and sourced, which might be a problem in restricted environments where accessing to temporary directories are restricted or where file IO is relatively expensive. Besides, the temporary files are often left undeleted despite the rm line being sourced.

This PR proposes a way to print out the configuration headers through a new function optparse.compose, which can be evaluated (eval "$(optparse.compose)") or sourced (. <<(optparse.compose)) in the user scripts to include the configurations without the need of temporary files.

The changes are a backward-compatible, as optparse.build now write to the temporary file the result of optparse.compose plus the line remove $tempfile.

This PR also include some house-keeping such as removing trailing white spaces and tabs from the generated result, sample_head.sh and README.md.

ShamrockLee avatar Jan 01 '22 16:01 ShamrockLee