tomkyle / negatives-linear-tiff

Converts RAW/NEF/CR2 files into linear TIFF files, using GNU Parallel for maximum speed. Other features: B/W grayscaling, TIF resizing and ZIP compression.
https://tomkyle.github.io/negatives-linear-tiff
Other
7 stars 1 forks source link

Dependency injection for functions #5

Open tomkyle opened 7 years ago

tomkyle commented 7 years ago

So this script is refactored to a main function and some helper functions as well. Nice. All of them on the global level. Not so nice, as the code blocks are not self-containing any longer.

To make sure everything is self-containing again and to prepare for unit testing, all functions should receive the stuff they need as parameter.


function Foo {
  echo "Foo!"
}

function main {
    local local_foo=$1
    shift
    # Call dependency. Output should be "Foo!"
    ($local_foo)
}
main Foo "${@}"