Fix errors with variable names with hyphen in git setup scripts

Specifically, several of the git setup scripts defined a function
named "egrep-q". This almost always works, but I happened to have
an install of git on windows/cygwin that gave the error:

    `egrep-q': not a valid identifier

I always thought hyphens were allowed in script identifiers (and
usually they are), but apparently sometimes they are not. (See
for example
https://stackoverflow.com/questions/2821043/allowed-characters-in-linux-environment-variable-names).
This provides an easy fix by replacing egrep-q with egrep_q.
This commit is contained in:
Kenneth Moreland 2017-09-19 10:40:51 -06:00
parent c799f262e9
commit a0ba2765f7
5 changed files with 11 additions and 11 deletions

@ -35,7 +35,7 @@ OPTIONS_SPEC=
SUBDIRECTORY_OK=Yes
. "$(git --exec-path)/git-sh-setup"
egrep-q() {
egrep_q() {
egrep "$@" >/dev/null 2>/dev/null
}
@ -105,7 +105,7 @@ push without '-f' or '--force'."
fi
have_lease_flag=false
if git push -h | egrep-q -e '--force-with-lease'; then
if git push -h | egrep_q -e '--force-with-lease'; then
have_lease_flag=true
fi
@ -159,7 +159,7 @@ echo "$push_stdout"
if test "$push_exit" -ne 0 && test -z "$force"; then
# Advise the user to fetch if needed.
if echo "$push_stdout" | egrep-q 'stale info'; then
if echo "$push_stdout" | egrep_q 'stale info'; then
echo "
You have pushed to your branch from another machine; you may be overwriting
commits unintentionally. Fetch from the $remote remote and check that you are
@ -167,7 +167,7 @@ not pushing an outdated branch."
fi
# Advise the user to force-push if needed.
if echo "$push_stdout" | egrep-q 'non-fast-forward'; then
if echo "$push_stdout" | egrep_q 'non-fast-forward'; then
echo '
Add "-f" or "--force" to push a rewritten topic.'
fi

@ -30,7 +30,7 @@ OPTIONS_SPEC=
SUBDIRECTORY_OK=Yes
. "$(git --exec-path)/git-sh-setup"
egrep-q() {
egrep_q() {
egrep "$@" >/dev/null 2>/dev/null
}

@ -26,7 +26,7 @@
# hooks.url = Repository URL publishing "hooks" branch
# hooks.branch = Repository branch instead of "hooks"
egrep-q() {
egrep_q() {
egrep "$@" >/dev/null 2>/dev/null
}
@ -42,7 +42,7 @@ if url=$(git config --get hooks.url); then
# Fetch hooks from locally configured repository.
branch=$(git config hooks.branch || echo hooks)
elif git for-each-ref refs/remotes/origin/hooks 2>/dev/null |
egrep-q 'refs/remotes/origin/hooks$'; then
egrep_q 'refs/remotes/origin/hooks$'; then
# Use hooks cloned from origin.
url=.. && branch=remotes/origin/hooks
elif url=$(git config -f config --get hooks.url); then

@ -25,7 +25,7 @@
# ssh.key = Local ssh key name
# ssh.request-url = Web page URL to request ssh access
egrep-q() {
egrep_q() {
egrep "$@" >/dev/null 2>/dev/null
}
@ -45,7 +45,7 @@ die 'This project is not configured for ssh push access.'
# Check for existing configuration.
if test -r ~/.ssh/config &&
egrep-q 'Host[= ]'"${host//\./\\.}" ~/.ssh/config; then
egrep_q 'Host[= ]'"${host//\./\\.}" ~/.ssh/config; then
echo 'Host "'"$host"'" is already in ~/.ssh/config' &&
setup= &&
question='Test'

@ -19,7 +19,7 @@
# Project configuration instructions: NONE
egrep-q() {
egrep_q() {
egrep "$@" >/dev/null 2>/dev/null
}
@ -33,7 +33,7 @@ One may enable color output from Git commands with
fi
# Suggest bash completion.
if ! bash -i -c 'echo $PS1' | egrep-q '__git_ps1'; then
if ! bash -i -c 'echo $PS1' | egrep_q '__git_ps1'; then
echo '
A dynamic, informative Git shell prompt can be obtained by sourcing
the git bash-completion script in your "~/.bashrc". Set the PS1