#!/bin/sh
# Copyright (C) 2012 G.P. Halkes
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3, as
# published by the Free Software Foundation.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
CAT=cat
for OPT
do
case "$OPT" in
--)
shift
break
;;
-s|--strip-comments)
shift
CAT=strip_comments
;;
-h|--help)
echo "Usage: data2byes [] []"
echo " -s,--strip-comments Remove lines which start with # and leading whitespace"
exit 1
;;
*)
break
;;
esac
done
strip_comments() {
sed 's/^[[:space:]][[:space:]]*//;/^#/d;/^$/d' -- "$@"
}
$CAT "$@" | od -An -v -tx1 | sed 's/\([0-9a-fA-F][0-9a-fA-F]\)/0x\1,/g;$s/, *$//'