Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
b8a41ce1e0
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
executable file 65 lines (61 sloc) 1.33 KB
#!/bin/bash
# usage: [required_input ...]
# --optional [optional_inputs ...]
# --required [required_inputs ...]
# --output=[output]
# [--skip-mtime]
# This script will fail if all inputs are older than the output file or if
# the output file does not exits.
# If --skip-mtime is provided, only the existance of files will be checked.
# Parse command line args
inputs=()
optional_inputs=()
optional=false
skip_mtime=false
for i in "$@"
do
case $i in
--output=*)
output="${i#*=}"
shift
;;
--skip-mtime)
skip_mtime=true
shift
;;
--optional)
optional=true
shift
;;
--required)
optional=false
shift
;;
*)
if [[ $optional = true ]]; then
optional_inputs+=($i)
else
inputs+=($i)
fi
shift
;;
esac
done
for input in ${inputs[@]}; do
if [[ ! -f $input ]]; then
exit 1
fi
done
if [[ ! -f $output ]]; then
exit 0
fi
if [[ $skip_mtime = true ]]; then
exit 0
fi
all_inputs=(${inputs[@]} ${optional_inputs[@]})
for input in ${all_inputs[@]}; do
if [[ -f $input ]] && [[ $output -ot $input ]]; then
exit 0
fi
done
exit 1