Fix paper build tool to work with zsh.

This commit is contained in:
DemonWav 2016-04-03 21:36:19 -05:00 committed by kashike
parent 13ca1593c5
commit afc619e188

13
paper
View File

@ -1,7 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# resolve shell-specifics # resolve shell-specifics
case "$SHELL" in case "$(echo "$SHELL" | sed 's|/usr||g')" in
"/bin/zsh") "/bin/zsh")
RCPATH="$HOME/.zshrc" RCPATH="$HOME/.zshrc"
SOURCE="${BASH_SOURCE[0]:-${(%):-%N}}" SOURCE="${BASH_SOURCE[0]:-${(%):-%N}}"
@ -14,6 +14,7 @@ case "$SHELL" in
SOURCE="${BASH_SOURCE[0]}" SOURCE="${BASH_SOURCE[0]}"
;; ;;
esac esac
# get base dir regardless of execution location # get base dir regardless of execution location
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
@ -64,6 +65,13 @@ case "$1" in
fi fi
) )
;; ;;
"m" | "mcdev")
(
set -e
cd "$basedir"
scripts/makemcdevsrc.sh "$basedir"
)
;;
"r" | "root") "r" | "root")
cd "$basedir" cd "$basedir"
;; ;;
@ -122,7 +130,7 @@ case "$1" in
if [[ ! -z "${2+x}" ]] ; then if [[ ! -z "${2+x}" ]] ; then
NAME="$2" NAME="$2"
fi fi
(grep "alias $NAME=" "$RCPATH" > /dev/null) && (sed -i "s|alias $NAME=.*|alias $NAME='.$SOURCE'|g" "$RCPATH") || (echo "alias $NAME='. $SOURCE'" >> "$RCPATH") (grep "alias $NAME=" "$RCPATH" > /dev/null) && (sed -i "s|alias $NAME=.*|alias $NAME='. $SOURCE'|g" "$RCPATH") || (echo "alias $NAME='. $SOURCE'" >> "$RCPATH")
alias "$NAME=. $SOURCE" alias "$NAME=. $SOURCE"
echo "You can now just type '$NAME' at any time to access the paper tool." echo "You can now just type '$NAME' at any time to access the paper tool."
else else
@ -138,6 +146,7 @@ case "$1" in
echo " * rb, rbp, rebuild | Rebuild patches, can be called from anywhere." echo " * rb, rbp, rebuild | Rebuild patches, can be called from anywhere."
echo " * p, patch | Apply all patches to the project without building it. Can be run from anywhere." echo " * p, patch | Apply all patches to the project without building it. Can be run from anywhere."
echo " * j, jar | Apply all patches and build the project, paperclip.jar will be output. Can be run from anywhere." echo " * j, jar | Apply all patches and build the project, paperclip.jar will be output. Can be run from anywhere."
echo " * m, mcdev | Setup decompiled sources for non-modified NMS files to be imported into an IDE. Can be run from anywhere."
echo "" echo ""
echo " These commands require the setup command before use:" echo " These commands require the setup command before use:"
echo " * r, root | Change directory to the root of the project." echo " * r, root | Change directory to the root of the project."