set -e
set -u
-VERSION="0.2.0"
+VERSION="0.3.0"
MY_BASE=$(basename "${0}")
#--------------------------------------------
usage() {
cat <<EOF
-Usage: ${0} [-d] [-v] [-t] <IMAGE_FILE> [COMMENT]
+Usage: ${0} [-d|--debug] [-v|--verbose] [-t|--test] [-r|--replace] <IMAGE_FILE> [COMMENT]
${0} {-h|--help}
${0} {-V|--version}
+Options:
+ -d|--debug debug output (bash -x)
+ -v|--verbose Set verbosity on.
+ -t|--test test (simulation) mode - comment will not be applied
+ -h|--help show this output and exit
+ -V|--version prints out version number of the script and exit
+
EOF
}
debug="n"
verbose="n"
simulate="n"
+replace="n"
set +e
-TEMP=$( getopt -o dvthV --long debug,verbose,simulate,test,help,version -n "${MY_BASE}" -- "$@" )
+TEMP=$( getopt -o dvtrhV --long debug,verbose,simulate,replace,test,help,version -n "${MY_BASE}" -- "$@" )
if [[ $? != 0 ]] ; then
echo "" >&2
usage >&2
simulate="y"
shift
;;
+ -r|--replace)
+ replace="y"
+ shift
+ ;;
-h|--help)
usage
exit 0
CUR_COMMENT=$( rdjpgcom "${IMAGE_FILE}" )
trap - INT TERM EXIT
+show_old="n"
+if [[ "$#" -lt 1 || "${verbose}" = "y" ]] ; then
+ show_old="y"
+fi
+
+if [[ "${show_old}" = "y" ]] ; then
+ if [[ -n "${CUR_COMMENT}" ]] ; then
+ echo "Current JPEG comment in '${IMAGE_FILE}': ${CUR_COMMENT}"
+ else
+ echo "File '${IMAGE_FILE}' has no JPEG comment."
+ fi
+fi
+
+if [[ "$#" -lt 1 ]] ; then
+ exit 0
+fi
+
+if type -t jhead >/dev/null ; then
+ :
+else
+ cat >&2 <<-EOF
+ Executable jhead not found.
+
+ Please install package jhead (Debian/Ubuntu) or media-gfx/jhead (Gentoo).
+
+ EOF
+ exit 5
+fi
+
+NEW_COMMENT="$*"
+
+
# vim: et ts=4 softtabstop