summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a6828f5)
raw | patch | inline | side by side (parent: a6828f5)
author | Jeff King <peff@peff.net> | |
Wed, 12 Mar 2008 21:29:57 +0000 (17:29 -0400) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Thu, 13 Mar 2008 04:10:00 +0000 (21:10 -0700) |
Specifying character ranges in tr differs between System V
and POSIX. In System V, brackets are required (e.g.,
'[A-Z]'), whereas in POSIX they are not.
We can mostly get around this by just using the bracket form
for both sets, as in:
tr '[A-Z] '[a-z]'
in which case POSIX interpets this as "'[' becomes '['",
which is OK.
However, this doesn't work with multiple sequences, like:
# rot13
tr '[A-Z][a-z]' '[N-Z][A-M][n-z][a-m]'
where the POSIX version does not behave the same as the
System V version. In this case, we must simply enumerate the
sequence.
This patch fixes problematic uses of tr in git scripts and
test scripts in one of three ways:
- if a single sequence, make sure it uses brackets
- if multiple sequences, enumerate
- if extra brackets (e.g., tr '[A]' 'a'), eliminate
brackets
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
and POSIX. In System V, brackets are required (e.g.,
'[A-Z]'), whereas in POSIX they are not.
We can mostly get around this by just using the bracket form
for both sets, as in:
tr '[A-Z] '[a-z]'
in which case POSIX interpets this as "'[' becomes '['",
which is OK.
However, this doesn't work with multiple sequences, like:
# rot13
tr '[A-Z][a-z]' '[N-Z][A-M][n-z][a-m]'
where the POSIX version does not behave the same as the
System V version. In this case, we must simply enumerate the
sequence.
This patch fixes problematic uses of tr in git scripts and
test scripts in one of three ways:
- if a single sequence, make sure it uses brackets
- if multiple sequences, enumerate
- if extra brackets (e.g., tr '[A]' 'a'), eliminate
brackets
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-bisect.sh | patch | blob | history | |
git-filter-branch.sh | patch | blob | history | |
t/t4022-diff-rewrite.sh | patch | blob | history | |
t/t7003-filter-branch.sh | patch | blob | history |
diff --git a/git-bisect.sh b/git-bisect.sh
index 2c32d0b9ebcdb9bf43124721e109cfac72149990..48fb92d612f065166072e09f49ee4c1e58b34a3a 100755 (executable)
--- a/git-bisect.sh
+++ b/git-bisect.sh
bisect_next_check good
skip=$(git for-each-ref --format='%(objectname)' \
- "refs/bisect/skip-*" | tr '[\012]' ' ') || exit
+ "refs/bisect/skip-*" | tr '\012' ' ') || exit
BISECT_OPT=''
test -n "$skip" && BISECT_OPT='--bisect-all'
bad=$(git rev-parse --verify refs/bisect/bad) &&
good=$(git for-each-ref --format='^%(objectname)' \
- "refs/bisect/good-*" | tr '[\012]' ' ') &&
+ "refs/bisect/good-*" | tr '\012' ' ') &&
eval="git rev-list --bisect-vars $BISECT_OPT $good $bad --" &&
eval="$eval $(cat "$GIT_DIR/BISECT_NAMES")" &&
eval=$(filter_skipped "$eval" "$skip") &&
diff --git a/git-filter-branch.sh b/git-filter-branch.sh
index 010353ad82881886b9739cc5f8de595acc9273ef..59cf023d5da068eaad4a1cef661015a42c34e703 100755 (executable)
--- a/git-filter-branch.sh
+++ b/git-filter-branch.sh
# "author" or "committer
set_ident () {
- lid="$(echo "$1" | tr "A-Z" "a-z")"
- uid="$(echo "$1" | tr "a-z" "A-Z")"
+ lid="$(echo "$1" | tr "[A-Z]" "[a-z]")"
+ uid="$(echo "$1" | tr "[a-z]" "[A-Z]")"
pick_id_script='
/^'$lid' /{
s/'\''/'\''\\'\'\''/g
index 6de4acbd44589fbcf6a3f9c4ca2043c9f4e99ebe..bf996fc414d3b5ea16488a8b274973a8347b29cb 100755 (executable)
--- a/t/t4022-diff-rewrite.sh
+++ b/t/t4022-diff-rewrite.sh
cat ../../COPYING >test &&
git add test &&
- tr 'a-zA-Z' 'n-za-mN-ZA-M' <../../COPYING >test
+ tr \
+ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" \
+ "nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM" \
+ <../../COPYING >test
'
index 6e14bf1c7f0991bbaab217e8a08bae0cacfe1ab1..553131fcf4cc418309e0cb750d885a5fbfe0fe47 100755 (executable)
--- a/t/t7003-filter-branch.sh
+++ b/t/t7003-filter-branch.sh
. ./test-lib.sh
make_commit () {
- lower=$(echo $1 | tr A-Z a-z)
+ lower=$(echo $1 | tr '[A-Z]' '[a-z]')
echo $lower > $lower
git add $lower
test_tick