set -e
set -u
+VERSION="0.2.0"
+MY_BASE=$(basename "${0}")
+#--------------------------------------------
usage() {
cat <<EOF
-Usage: ${0} <IMAGE_FILE> [COMMENT]
+Usage: ${0} [-d] [-v] [-t] <IMAGE_FILE> [COMMENT]
+ ${0} {-h|--help}
+ ${0} {-V|--version}
EOF
}
+IMAGE_FILE=
+
+#--------------------------------------------
+print_file() {
+ if [[ -n "${IMAGE_FILE}" ]] ; then
+ printf "%s: not applicable.\n\n" "${IMAGE_FILE}" >&2
+ fi
+}
+
+#--------------------------------------------
+debug="n"
+verbose="n"
+simulate="n"
+
+set +e
+TEMP=$( getopt -o dvthV --long debug,verbose,simulate,test,help,version -n "${MY_BASE}" -- "$@" )
+if [[ $? != 0 ]] ; then
+ echo "" >&2
+ usage >&2
+ exit 1
+fi
+set -e
+
+# Note the quotes around `$TEMP': they are essential!
+eval set -- "$TEMP"
+
+while true ; do
+ case "$1" in
+ -d|--debug)
+ debug="y"
+ shift
+ ;;
+ -v|--verbose)
+ verbose="y"
+ shift
+ ;;
+ -t|--test|--simulate)
+ simulate="y"
+ shift
+ ;;
+ -h|--help)
+ usage
+ exit 0
+ ;;
+ -V|--version)
+ echo "${MY_BASE} version: ${VERSION}"
+ exit 0
+ ;;
+ --) shift
+ break
+ ;;
+ *) echo "Unknown parameter '${1}'" >&2
+ usage >&2
+ exit 1
+ ;;
+ esac
+done
+
+if [[ "${debug}" = "y" ]] ; then
+ set -x
+fi
+
+
+#--------------------------------------------
if [[ "$#" -lt 1 ]] ; then
echo -e "No image file given.\n" >&2
usage >&2
:
else
cat >&2 <<-EOF
- Executable rdjpgcom not found.
+ Executable rdjpgcom not found.
Please install package libjpeg-progs (Debian/Ubuntu) or media-libs/libjpeg-turbo (Gentoo).
exit 1
fi
+trap "print_file; exit 1" INT TERM EXIT
+CUR_COMMENT=$( rdjpgcom "${IMAGE_FILE}" )
+trap - INT TERM EXIT
+
# vim: et ts=4 softtabstop