mirror of
https://github.com/dashpay/dash.git
synced 2024-12-24 19:42:46 +01:00
a7a3ecc354
13a81b19d
Add quotes to variable assignment (as requested by @TheBlueMatt) (practicalswift)683b9d280
Fix valid path output (practicalswift)193c2fb4c
Use bash instead of POSIX sh. POSIX sh does not support arrays. (practicalswift)80f5f28d3
Fix incorrect quoting of quotes (the previous quotes had no effect beyond unquoting) (practicalswift)564a172df
Add required space to [[ -n "$1" ]] (previously [[ -n"$1" ]]) (practicalswift)1e44ae0e1
Add error handling: exit if cd fails (practicalswift)b9e79ab41
Remove "\n" from echo argument. echo does not support escape sequences. (practicalswift)f6b3382fa
Remove unused variables (practicalswift) Pull request description: Shell script cleanups: * Add required space to `[ -n ]`. * Avoid quote within quote. * Exit if `cd` fails. * Remove `\n` which is not handled by `echo`. * ~~Remove redundant `$` in arithmetic variable expression.~~ * ~~Use `$(command)` instead of legacy form `` `command` ``.~~ * Arrays are not supported in POSIX `sh`. Use `bash` when arrays are used. * ~~`[ foo -a bar ]` is not well defined, use `[ foo ] && [ bar ]` instead.~~ * ~~`[ foo -o bar ]` is not well defined, use `[ foo ] || [ bar ]` instead.~~ Tree-SHA512: 80f6ded58bce625b15b4da30d69d2714c633e184e62b21ed67d2c58e2ebaa08b4147593324012694d02bf4f1f252844cdff2fd1cf5e817ddb07e2777db7a6390
53 lines
1.6 KiB
Bash
Executable File
53 lines
1.6 KiB
Bash
Executable File
#!/bin/sh
|
|
# Copyright (c) 2012-2016 The Bitcoin Core developers
|
|
# Distributed under the MIT software license, see the accompanying
|
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
if [ $# -gt 1 ]; then
|
|
cd "$2" || exit 1
|
|
fi
|
|
if [ $# -gt 0 ]; then
|
|
FILE="$1"
|
|
shift
|
|
if [ -f "$FILE" ]; then
|
|
INFO="$(head -n 1 "$FILE")"
|
|
fi
|
|
else
|
|
echo "Usage: $0 <filename> <srcroot>"
|
|
exit 1
|
|
fi
|
|
|
|
git_check_in_repo() {
|
|
! { git status --porcelain -uall --ignored "$@" 2>/dev/null || echo '??'; } | grep -q '?'
|
|
}
|
|
|
|
DESC=""
|
|
SUFFIX=""
|
|
if [ "${BITCOIN_GENBUILD_NO_GIT}" != "1" -a -e "$(which git 2>/dev/null)" -a "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ] && git_check_in_repo share/genbuild.sh; then
|
|
# clean 'dirty' status of touched files that haven't been modified
|
|
git diff >/dev/null 2>/dev/null
|
|
|
|
# if latest commit is tagged and not dirty, then override using the tag name
|
|
RAWDESC=$(git describe --abbrev=0 2>/dev/null)
|
|
if [ "$(git rev-parse HEAD)" = "$(git rev-list -1 $RAWDESC 2>/dev/null)" ]; then
|
|
git diff-index --quiet HEAD -- && DESC=$RAWDESC
|
|
fi
|
|
|
|
# otherwise generate suffix from git, i.e. string like "59887e8-dirty"
|
|
SUFFIX=$(git rev-parse --short HEAD)
|
|
git diff-index --quiet HEAD -- || SUFFIX="$SUFFIX-dirty"
|
|
fi
|
|
|
|
if [ -n "$DESC" ]; then
|
|
NEWINFO="#define BUILD_DESC \"$DESC\""
|
|
elif [ -n "$SUFFIX" ]; then
|
|
NEWINFO="#define BUILD_SUFFIX $SUFFIX"
|
|
else
|
|
NEWINFO="// No build information available"
|
|
fi
|
|
|
|
# only update build.h if necessary
|
|
if [ "$INFO" != "$NEWINFO" ]; then
|
|
echo "$NEWINFO" >"$FILE"
|
|
fi
|