jsnes/create-xdc.sh
B. Petersen 26f34a767b
be more tolerant on PACKAGE_NAME argument
when a package name is given to `create-xdc.sh`,
this may be just a copy+pasted filename.
that, however, results in double `.xdc` extensions.

this pr accepts PACKAGE_NAME with or without .xdc extensions,
of course, when creating the final ZIP, .xdc is always added,
however only once :)

moreover, this pr documents the weird string manipulation commands.
2022-01-09 16:12:49 +01:00

21 lines
568 B
Bash
Executable file

#!/bin/sh
case "$1" in
"-h" | "--help")
echo "usage: ${0##*/} [PACKAGE_NAME]"
exit
;;
"")
PACKAGE_NAME=${PWD##*/} # '##*/' removes everything before the last slash and the last slash
;;
*)
PACKAGE_NAME=${1%.xdc} # '%.xdc' removes the extension and allows PACKAGE_NAME to be given with or without extension
;;
esac
rm $PACKAGE_NAME.xdc 2> /dev/null
zip -9 --recurse-paths $PACKAGE_NAME.xdc * --exclude README.md webxdc.js "*.sh" "*.xdc"
echo "success, archive contents:"
unzip -l $PACKAGE_NAME.xdc