remove use of "tail -n 1" and "tail -1"

The "-n" syntax is not supported by System V versions of
tail (which prefer "tail -1"). Unfortunately "tail -1" is
not actually POSIX.  We had some of both forms in our
scripts.

Since neither form works everywhere, this patch replaces
both with the equivalent sed invocation:

  sed -ne '$p'

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Jeff King 2008-03-12 17:34:34 -04:00 committed by Junio C Hamano
parent aadbe44f88
commit b4ce54fc61
7 changed files with 20 additions and 20 deletions

View File

@ -357,7 +357,7 @@ do
LAST_SIGNED_OFF_BY=` LAST_SIGNED_OFF_BY=`
sed -ne '/^Signed-off-by: /p' \ sed -ne '/^Signed-off-by: /p' \
"$dotest/msg-clean" | "$dotest/msg-clean" |
tail -n 1 sed -ne '$p'
` `
ADD_SIGNOFF=` ADD_SIGNOFF=`
test "$LAST_SIGNED_OFF_BY" = "$SIGNOFF" || { test "$LAST_SIGNED_OFF_BY" = "$SIGNOFF" || {

View File

@ -218,7 +218,7 @@ nth_string () {
make_squash_message () { make_squash_message () {
if test -f "$SQUASH_MSG"; then if test -f "$SQUASH_MSG"; then
COUNT=$(($(sed -n "s/^# This is [^0-9]*\([1-9][0-9]*\).*/\1/p" \ COUNT=$(($(sed -n "s/^# This is [^0-9]*\([1-9][0-9]*\).*/\1/p" \
< "$SQUASH_MSG" | tail -n 1)+1)) < "$SQUASH_MSG" | sed -ne '$p')+1))
echo "# This is a combination of $COUNT commits." echo "# This is a combination of $COUNT commits."
sed -e 1d -e '2,/^./{ sed -e 1d -e '2,/^./{
/^$/d /^$/d

View File

@ -122,8 +122,8 @@ test_expect_success 'reflog for the branch shows state before rebase' '
test_expect_success 'exchange two commits' ' test_expect_success 'exchange two commits' '
FAKE_LINES="2 1" git rebase -i HEAD~2 && FAKE_LINES="2 1" git rebase -i HEAD~2 &&
test H = $(git cat-file commit HEAD^ | tail -n 1) && test H = $(git cat-file commit HEAD^ | sed -ne \$p) &&
test G = $(git cat-file commit HEAD | tail -n 1) test G = $(git cat-file commit HEAD | sed -ne \$p)
' '
cat > expect << EOF cat > expect << EOF

View File

@ -103,7 +103,7 @@ test_expect_success \
test_expect_success \ test_expect_success \
'[index v1] 2) create a stealth corruption in a delta base reference' \ '[index v1] 2) create a stealth corruption in a delta base reference' \
'# this test assumes a delta smaller than 16 bytes at the end of the pack '# this test assumes a delta smaller than 16 bytes at the end of the pack
git show-index <1.idx | sort -n | tail -n 1 | ( git show-index <1.idx | sort -n | sed -ne \$p | (
read delta_offs delta_sha1 && read delta_offs delta_sha1 &&
git cat-file blob "$delta_sha1" > blob_1 && git cat-file blob "$delta_sha1" > blob_1 &&
chmod +w ".git/objects/pack/pack-${pack1}.pack" && chmod +w ".git/objects/pack/pack-${pack1}.pack" &&
@ -141,7 +141,7 @@ test_expect_success \
test_expect_success \ test_expect_success \
'[index v2] 2) create a stealth corruption in a delta base reference' \ '[index v2] 2) create a stealth corruption in a delta base reference' \
'# this test assumes a delta smaller than 16 bytes at the end of the pack '# this test assumes a delta smaller than 16 bytes at the end of the pack
git show-index <1.idx | sort -n | tail -n 1 | ( git show-index <1.idx | sort -n | sed -ne \$p | (
read delta_offs delta_sha1 delta_crc && read delta_offs delta_sha1 delta_crc &&
git cat-file blob "$delta_sha1" > blob_3 && git cat-file blob "$delta_sha1" > blob_3 &&
chmod +w ".git/objects/pack/pack-${pack1}.pack" && chmod +w ".git/objects/pack/pack-${pack1}.pack" &&

View File

@ -219,7 +219,7 @@ test_expect_success 'bisect run & skip: cannot tell between 2' '
add_line_into_file "6: Yet a line." hello && add_line_into_file "6: Yet a line." hello &&
HASH6=$(git rev-parse --verify HEAD) && HASH6=$(git rev-parse --verify HEAD) &&
echo "#"\!"/bin/sh" > test_script.sh && echo "#"\!"/bin/sh" > test_script.sh &&
echo "tail -1 hello | grep Ciao > /dev/null && exit 125" >> test_script.sh && echo "sed -ne \\\$p hello | grep Ciao > /dev/null && exit 125" >> test_script.sh &&
echo "grep line hello > /dev/null" >> test_script.sh && echo "grep line hello > /dev/null" >> test_script.sh &&
echo "test \$? -ne 0" >> test_script.sh && echo "test \$? -ne 0" >> test_script.sh &&
chmod +x test_script.sh && chmod +x test_script.sh &&
@ -244,8 +244,8 @@ test_expect_success 'bisect run & skip: find first bad' '
add_line_into_file "7: Should be the last line." hello && add_line_into_file "7: Should be the last line." hello &&
HASH7=$(git rev-parse --verify HEAD) && HASH7=$(git rev-parse --verify HEAD) &&
echo "#"\!"/bin/sh" > test_script.sh && echo "#"\!"/bin/sh" > test_script.sh &&
echo "tail -1 hello | grep Ciao > /dev/null && exit 125" >> test_script.sh && echo "sed -ne \\\$p hello | grep Ciao > /dev/null && exit 125" >> test_script.sh &&
echo "tail -1 hello | grep day > /dev/null && exit 125" >> test_script.sh && echo "sed -ne \\\$p hello | grep day > /dev/null && exit 125" >> test_script.sh &&
echo "grep Yet hello > /dev/null" >> test_script.sh && echo "grep Yet hello > /dev/null" >> test_script.sh &&
echo "test \$? -ne 0" >> test_script.sh && echo "test \$? -ne 0" >> test_script.sh &&
chmod +x test_script.sh && chmod +x test_script.sh &&

View File

@ -165,7 +165,7 @@ verify_mergeheads() {
fi && fi &&
while test $# -gt 0 while test $# -gt 0
do do
head=$(head -n $i .git/MERGE_HEAD | tail -n 1) head=$(head -n $i .git/MERGE_HEAD | sed -ne \$p)
if test "$1" != "$head" if test "$1" != "$head"
then then
echo "[OOPS] MERGE_HEAD $i != $1" echo "[OOPS] MERGE_HEAD $i != $1"

View File

@ -54,7 +54,7 @@ test_expect_success 'setup' '
test_expect_success 'basic checkout' \ test_expect_success 'basic checkout' \
'GIT_CONFIG="$git_config" cvs -Q co -d cvswork master && 'GIT_CONFIG="$git_config" cvs -Q co -d cvswork master &&
test "$(echo $(grep -v ^D cvswork/CVS/Entries|cut -d/ -f2,3,5 | head -n 1))" = "empty/1.1/" test "$(echo $(grep -v ^D cvswork/CVS/Entries|cut -d/ -f2,3,5 | head -n 1))" = "empty/1.1/"
test "$(echo $(grep -v ^D cvswork/CVS/Entries|cut -d/ -f2,3,5 | tail -n 1))" = "secondrootfile/1.1/"' test "$(echo $(grep -v ^D cvswork/CVS/Entries|cut -d/ -f2,3,5 | sed -ne \$p))" = "secondrootfile/1.1/"'
#------------------------ #------------------------
# PSERVER AUTHENTICATION # PSERVER AUTHENTICATION
@ -94,7 +94,7 @@ EOF
test_expect_success 'pserver authentication' \ test_expect_success 'pserver authentication' \
'cat request-anonymous | git-cvsserver pserver >log 2>&1 && 'cat request-anonymous | git-cvsserver pserver >log 2>&1 &&
tail -n1 log | grep "^I LOVE YOU$"' sed -ne \$p log | grep "^I LOVE YOU$"'
test_expect_success 'pserver authentication failure (non-anonymous user)' \ test_expect_success 'pserver authentication failure (non-anonymous user)' \
'if cat request-git | git-cvsserver pserver >log 2>&1 'if cat request-git | git-cvsserver pserver >log 2>&1
@ -103,11 +103,11 @@ test_expect_success 'pserver authentication failure (non-anonymous user)' \
else else
true true
fi && fi &&
tail -n1 log | grep "^I HATE YOU$"' sed -ne \$p log | grep "^I HATE YOU$"'
test_expect_success 'pserver authentication (login)' \ test_expect_success 'pserver authentication (login)' \
'cat login-anonymous | git-cvsserver pserver >log 2>&1 && 'cat login-anonymous | git-cvsserver pserver >log 2>&1 &&
tail -n1 log | grep "^I LOVE YOU$"' sed -ne \$p log | grep "^I LOVE YOU$"'
test_expect_success 'pserver authentication failure (login/non-anonymous user)' \ test_expect_success 'pserver authentication failure (login/non-anonymous user)' \
'if cat login-git | git-cvsserver pserver >log 2>&1 'if cat login-git | git-cvsserver pserver >log 2>&1
@ -116,7 +116,7 @@ test_expect_success 'pserver authentication failure (login/non-anonymous user)'
else else
true true
fi && fi &&
tail -n1 log | grep "^I HATE YOU$"' sed -ne \$p log | grep "^I HATE YOU$"'
# misuse pserver authentication for testing of req_Root # misuse pserver authentication for testing of req_Root
@ -154,7 +154,7 @@ test_expect_success 'req_Root failure (conflicting roots)' \
test_expect_success 'req_Root (strict paths)' \ test_expect_success 'req_Root (strict paths)' \
'cat request-anonymous | git-cvsserver --strict-paths pserver $SERVERDIR >log 2>&1 && 'cat request-anonymous | git-cvsserver --strict-paths pserver $SERVERDIR >log 2>&1 &&
tail -n1 log | grep "^I LOVE YOU$"' sed -ne \$p log | grep "^I LOVE YOU$"'
test_expect_success 'req_Root failure (strict-paths)' ' test_expect_success 'req_Root failure (strict-paths)' '
! cat request-anonymous | ! cat request-anonymous |
@ -163,7 +163,7 @@ test_expect_success 'req_Root failure (strict-paths)' '
test_expect_success 'req_Root (w/o strict-paths)' \ test_expect_success 'req_Root (w/o strict-paths)' \
'cat request-anonymous | git-cvsserver pserver $WORKDIR/ >log 2>&1 && 'cat request-anonymous | git-cvsserver pserver $WORKDIR/ >log 2>&1 &&
tail -n1 log | grep "^I LOVE YOU$"' sed -ne \$p log | grep "^I LOVE YOU$"'
test_expect_success 'req_Root failure (w/o strict-paths)' ' test_expect_success 'req_Root failure (w/o strict-paths)' '
! cat request-anonymous | ! cat request-anonymous |
@ -181,7 +181,7 @@ EOF
test_expect_success 'req_Root (base-path)' \ test_expect_success 'req_Root (base-path)' \
'cat request-base | git-cvsserver --strict-paths --base-path $WORKDIR/ pserver $SERVERDIR >log 2>&1 && 'cat request-base | git-cvsserver --strict-paths --base-path $WORKDIR/ pserver $SERVERDIR >log 2>&1 &&
tail -n1 log | grep "^I LOVE YOU$"' sed -ne \$p log | grep "^I LOVE YOU$"'
test_expect_success 'req_Root failure (base-path)' ' test_expect_success 'req_Root failure (base-path)' '
! cat request-anonymous | ! cat request-anonymous |
@ -192,14 +192,14 @@ GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled false || exit 1
test_expect_success 'req_Root (export-all)' \ test_expect_success 'req_Root (export-all)' \
'cat request-anonymous | git-cvsserver --export-all pserver $WORKDIR >log 2>&1 && 'cat request-anonymous | git-cvsserver --export-all pserver $WORKDIR >log 2>&1 &&
tail -n1 log | grep "^I LOVE YOU$"' sed -ne \$p log | grep "^I LOVE YOU$"'
test_expect_success 'req_Root failure (export-all w/o whitelist)' \ test_expect_success 'req_Root failure (export-all w/o whitelist)' \
'! (cat request-anonymous | git-cvsserver --export-all pserver >log 2>&1 || false)' '! (cat request-anonymous | git-cvsserver --export-all pserver >log 2>&1 || false)'
test_expect_success 'req_Root (everything together)' \ test_expect_success 'req_Root (everything together)' \
'cat request-base | git-cvsserver --export-all --strict-paths --base-path $WORKDIR/ pserver $SERVERDIR >log 2>&1 && 'cat request-base | git-cvsserver --export-all --strict-paths --base-path $WORKDIR/ pserver $SERVERDIR >log 2>&1 &&
tail -n1 log | grep "^I LOVE YOU$"' sed -ne \$p log | grep "^I LOVE YOU$"'
GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled true || exit 1 GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled true || exit 1