blob: fa2004390c047de4376137a38e6c3d2853fc6f92 [file] [log] [blame] [raw]
#!/bin/sh
# Copyright 2015-2023 Rivoreo
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
# IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
src_dir="${0%/*}"
if [ "$src_dir" != "$0" ] && [ "$src_dir" != . ] && [ "$src_dir" != "$PWD" ] && [ ! "$src_dir" -ef . ]; then
echo "Error: You must run this program under the directory where it resides" 1>&2
exit 1
fi
unset src_dir
#with_hexdump=
crypt_wrapper=crypt.hex.sh
for a in "$@"; do case "$a" in
--with-hexdump)
#with_hexdump=1
crypt_wrapper=crypt.raw.sh
;;
--without-hexdump)
#with_hexdump=
crypt_wrapper=crypt.hex.sh
;;
--help|-h)
printf 'Usage: %s [--with-hexdump]\n' "${0##*/}"
exit 0
;;
--)
break
;;
*)
echo \?
exit 255
;;
esac done
set -e
blank=
first_blank=
IFS=
while read -r line; do case "$line" in
"#!"*)
continue
;;
"")
echo
[ -n "$blank" ] && break
blank=1
if [ -z "$first_blank" ]; then
echo "# Encrypted history for bash(1)"
echo "# Automatically assembled code for sourcing from bashrc(5)"
first_blank=1
fi
;;
"# "*)
printf %s\\n "$line"
blank=
;;
esac done < "$0"
exec sed -E "/^[[:space:]]*#/d" xtea-ctr.sh "$crypt_wrapper" bashrc