| Left: | ||
| Right: |
| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #!/bin/bash | |
|
Sebastian Noack
2017/08/23 15:52:33
It seems the only reason this script requires bash
Vasily Kuznetsov
2017/08/23 16:29:39
Done.
| |
| 2 # | |
| 3 # This file is part of Adblock Plus <https://adblockplus.org/>, | |
| 4 # Copyright (C) 2006-2017 eyeo GmbH | |
|
Sebastian Noack
2017/08/23 15:52:33
We don't put the current year into the copyright h
Vasily Kuznetsov
2017/08/23 16:29:39
Done.
| |
| 5 # | |
| 6 # Adblock Plus is free software: you can redistribute it and/or modify | |
| 7 # it under the terms of the GNU General Public License version 3 as | |
| 8 # published by the Free Software Foundation. | |
| 9 # | |
| 10 # Adblock Plus is distributed in the hope that it will be useful, | |
| 11 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 13 # GNU General Public License for more details. | |
| 14 # | |
| 15 # You should have received a copy of the GNU General Public License | |
| 16 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | |
| 17 | |
|
Sebastian Noack
2017/08/23 15:52:32
It is best practice to put `set -eu` at the top of
Vasily Kuznetsov
2017/08/23 16:29:39
Done.
| |
| 18 if [[ "$1" == "" ]]; then | |
| 19 echo "usage: rapply.sh PATCH" | |
| 20 exit 1 | |
| 21 fi | |
| 22 | |
| 23 SRCFILE="$1" | |
| 24 TMPFILE="$TMPDIR/`basename $SRCFILE`" | |
|
Sebastian Noack
2017/08/23 15:52:32
Where does the variable TMPDIR comes from? I don't
Vasily Kuznetsov
2017/08/23 16:29:39
It comes from POSIX (see https://en.wikipedia.org/
| |
| 25 | |
| 26 if git st >/dev/null 2>&1; then | |
| 27 IMPORT="git apply" | |
| 28 elif hg st >/dev/null 2>&1; then | |
| 29 IMPORT="hg import --no-commit" | |
| 30 else | |
| 31 echo "No repository found in `pwd`" | |
| 32 exit 2 | |
| 33 fi | |
| 34 | |
| 35 if [[ "$SRCFILE" =~ ^https?:// ]]; then | |
| 36 curl "$SRCFILE" | patchconv >"$TMPFILE" || exit 1 | |
| 37 else | |
| 38 patchconv <"$SRCFILE" >"$TMPFILE" || exit 1 | |
|
Sebastian Noack
2017/08/23 15:52:33
Nit: Please add a space before and after the angle
Vasily Kuznetsov
2017/08/23 16:29:39
Done.
| |
| 39 fi | |
| 40 | |
| 41 $IMPORT "$TMPFILE" | |
|
Sebastian Noack
2017/08/23 15:52:32
It seems the temporary file is not cleaned up. But
Vasily Kuznetsov
2017/08/23 16:29:39
You're right, that's better.
Done.
| |
| OLD | NEW |