Archiviert
13
0

Fix paper build tool to work with zsh.

Dieser Commit ist enthalten in:
DemonWav 2016-04-03 21:36:19 -05:00 committet von kashike
Ursprung 13ca1593c5
Commit afc619e188

37
paper
Datei anzeigen

@ -1,24 +1,25 @@
#!/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}}"
;; ;;
*) *)
RCPATH="$HOME/.bashrc" RCPATH="$HOME/.bashrc"
if [[ -f "$HOME/.bash_aliases" ]]; then if [[ -f "$HOME/.bash_aliases" ]]; then
RCPATH="$HOME/.bash_aliases" RCPATH="$HOME/.bash_aliases"
fi fi
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 )"
SOURCE="$(readlink "$SOURCE")" SOURCE="$(readlink "$SOURCE")"
[[ "$SOURCE" != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located [[ "$SOURCE" != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done done
SOURCE=$([[ "$SOURCE" = /* ]] && echo "$SOURCE" || echo "$PWD/${SOURCE#./}") SOURCE=$([[ "$SOURCE" = /* ]] && echo "$SOURCE" || echo "$PWD/${SOURCE#./}")
basedir=$(dirname "$SOURCE") basedir=$(dirname "$SOURCE")
@ -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."