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>
Jeff King committed
Mar 12, 2008 at 17:34 UTC
b4ce54fc61e7c76e2d7f47c34733f0f0bbb6c4cd
7 files changed
+20
-20
git-am.sh
+1
-1
@@ -357,7 +357,7 @@ do
357
LAST_SIGNED_OFF_BY=`
358
sed -ne '/^Signed-off-by: /p' \
359
"$dotest/msg-clean" |
360
- tail -n 1
360
+ sed -ne '$p'
361
`
362
ADD_SIGNOFF=`
363
test "$LAST_SIGNED_OFF_BY" = "$SIGNOFF" || {
git-rebase--interactive.sh
+1
-1
@@ -218,7 +218,7 @@ nth_string () {
218
make_squash_message () {
219
if test -f "$SQUASH_MSG"; then
220
COUNT=$(($(sed -n "s/^# This is [^0-9]*\([1-9][0-9]*\).*/\1/p" \
221
- < "$SQUASH_MSG" | tail -n 1)+1))
221
+ < "$SQUASH_MSG" | sed -ne '$p')+1))
222
echo "# This is a combination of $COUNT commits."
223
sed -e 1d -e '2,/^./{
224
/^$/d
t/t3404-rebase-interactive.sh
+2
-2
@@ -122,8 +122,8 @@ test_expect_success 'reflog for the branch shows state before rebase' '
122
123
test_expect_success 'exchange two commits' '
124
FAKE_LINES="2 1" git rebase -i HEAD~2 &&
125
- test H = $(git cat-file commit HEAD^ | tail -n 1) &&
126
- test G = $(git cat-file commit HEAD | tail -n 1)
125
+ test H = $(git cat-file commit HEAD^ | sed -ne \$p) &&
126
+ test G = $(git cat-file commit HEAD | sed -ne \$p)
127
'
128
129
cat > expect << EOF
t/t5302-pack-index.sh
+2
-2
@@ -103,7 +103,7 @@ test_expect_success \
103
test_expect_success \
104
'[index v1] 2) create a stealth corruption in a delta base reference' \
105
'# this test assumes a delta smaller than 16 bytes at the end of the pack
106
- git show-index <1.idx | sort -n | tail -n 1 | (
106
+ git show-index <1.idx | sort -n | sed -ne \$p | (
107
read delta_offs delta_sha1 &&
108
git cat-file blob "$delta_sha1" > blob_1 &&
109
chmod +w ".git/objects/pack/pack-${pack1}.pack" &&
@@ -141,7 +141,7 @@ test_expect_success \
141
test_expect_success \
142
'[index v2] 2) create a stealth corruption in a delta base reference' \
143
'# this test assumes a delta smaller than 16 bytes at the end of the pack
144
- git show-index <1.idx | sort -n | tail -n 1 | (
144
+ git show-index <1.idx | sort -n | sed -ne \$p | (
145
read delta_offs delta_sha1 delta_crc &&
146
git cat-file blob "$delta_sha1" > blob_3 &&
147
chmod +w ".git/objects/pack/pack-${pack1}.pack" &&
t/t6030-bisect-porcelain.sh
+3
-3
@@ -219,7 +219,7 @@ test_expect_success 'bisect run & skip: cannot tell between 2' '
219
add_line_into_file "6: Yet a line." hello &&
220
HASH6=$(git rev-parse --verify HEAD) &&
221
echo "#"\!"/bin/sh" > test_script.sh &&
222
- echo "tail -1 hello | grep Ciao > /dev/null && exit 125" >> test_script.sh &&
222
+ echo "sed -ne \\\$p hello | grep Ciao > /dev/null && exit 125" >> test_script.sh &&
223
echo "grep line hello > /dev/null" >> test_script.sh &&
224
echo "test \$? -ne 0" >> test_script.sh &&
225
chmod +x test_script.sh &&
@@ -244,8 +244,8 @@ test_expect_success 'bisect run & skip: find first bad' '
244
add_line_into_file "7: Should be the last line." hello &&
245
HASH7=$(git rev-parse --verify HEAD) &&
246
echo "#"\!"/bin/sh" > test_script.sh &&
247
- echo "tail -1 hello | grep Ciao > /dev/null && exit 125" >> test_script.sh &&
248
- echo "tail -1 hello | grep day > /dev/null && exit 125" >> test_script.sh &&
247
+ echo "sed -ne \\\$p hello | grep Ciao > /dev/null && exit 125" >> test_script.sh &&
248
+ echo "sed -ne \\\$p hello | grep day > /dev/null && exit 125" >> test_script.sh &&
249
echo "grep Yet hello > /dev/null" >> test_script.sh &&
250
echo "test \$? -ne 0" >> test_script.sh &&
251
chmod +x test_script.sh &&
t/t7600-merge.sh
+1
-1
@@ -165,7 +165,7 @@ verify_mergeheads() {
165
fi &&
166
while test $# -gt 0
167
do
168
- head=$(head -n $i .git/MERGE_HEAD | tail -n 1)
168
+ head=$(head -n $i .git/MERGE_HEAD | sed -ne \$p)
169
if test "$1" != "$head"
170
then
171
echo "[OOPS] MERGE_HEAD $i != $1"
t/t9400-git-cvsserver-server.sh
+10
-10
@@ -54,7 +54,7 @@ test_expect_success 'setup' '
54
test_expect_success 'basic checkout' \
55
'GIT_CONFIG="$git_config" cvs -Q co -d cvswork master &&
56
test "$(echo $(grep -v ^D cvswork/CVS/Entries|cut -d/ -f2,3,5 | head -n 1))" = "empty/1.1/"
57
- test "$(echo $(grep -v ^D cvswork/CVS/Entries|cut -d/ -f2,3,5 | tail -n 1))" = "secondrootfile/1.1/"'
57
+ test "$(echo $(grep -v ^D cvswork/CVS/Entries|cut -d/ -f2,3,5 | sed -ne \$p))" = "secondrootfile/1.1/"'
58
59
#------------------------
60
# PSERVER AUTHENTICATION
@@ -94,7 +94,7 @@ EOF
94
95
test_expect_success 'pserver authentication' \
96
'cat request-anonymous | git-cvsserver pserver >log 2>&1 &&
97
- tail -n1 log | grep "^I LOVE YOU$"'
97
+ sed -ne \$p log | grep "^I LOVE YOU$"'
98
99
test_expect_success 'pserver authentication failure (non-anonymous user)' \
100
'if cat request-git | git-cvsserver pserver >log 2>&1
@@ -103,11 +103,11 @@ test_expect_success 'pserver authentication failure (non-anonymous user)' \
103
else
104
true
105
fi &&
106
- tail -n1 log | grep "^I HATE YOU$"'
106
+ sed -ne \$p log | grep "^I HATE YOU$"'
107
108
test_expect_success 'pserver authentication (login)' \
109
'cat login-anonymous | git-cvsserver pserver >log 2>&1 &&
110
- tail -n1 log | grep "^I LOVE YOU$"'
110
+ sed -ne \$p log | grep "^I LOVE YOU$"'
111
112
test_expect_success 'pserver authentication failure (login/non-anonymous user)' \
113
'if cat login-git | git-cvsserver pserver >log 2>&1
@@ -116,7 +116,7 @@ test_expect_success 'pserver authentication failure (login/non-anonymous user)'
116
else
117
true
118
fi &&
119
- tail -n1 log | grep "^I HATE YOU$"'
119
+ sed -ne \$p log | grep "^I HATE YOU$"'
120
121
122
# misuse pserver authentication for testing of req_Root
@@ -154,7 +154,7 @@ test_expect_success 'req_Root failure (conflicting roots)' \
154
155
test_expect_success 'req_Root (strict paths)' \
156
'cat request-anonymous | git-cvsserver --strict-paths pserver $SERVERDIR >log 2>&1 &&
157
- tail -n1 log | grep "^I LOVE YOU$"'
157
+ sed -ne \$p log | grep "^I LOVE YOU$"'
158
159
test_expect_success 'req_Root failure (strict-paths)' '
160
! cat request-anonymous |
@@ -163,7 +163,7 @@ test_expect_success 'req_Root failure (strict-paths)' '
163
164
test_expect_success 'req_Root (w/o strict-paths)' \
165
'cat request-anonymous | git-cvsserver pserver $WORKDIR/ >log 2>&1 &&
166
- tail -n1 log | grep "^I LOVE YOU$"'
166
+ sed -ne \$p log | grep "^I LOVE YOU$"'
167
168
test_expect_success 'req_Root failure (w/o strict-paths)' '
169
! cat request-anonymous |
@@ -181,7 +181,7 @@ EOF
181
182
test_expect_success 'req_Root (base-path)' \
183
'cat request-base | git-cvsserver --strict-paths --base-path $WORKDIR/ pserver $SERVERDIR >log 2>&1 &&
184
- tail -n1 log | grep "^I LOVE YOU$"'
184
+ sed -ne \$p log | grep "^I LOVE YOU$"'
185
186
test_expect_success 'req_Root failure (base-path)' '
187
! cat request-anonymous |
@@ -192,14 +192,14 @@ GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled false || exit 1
192
193
test_expect_success 'req_Root (export-all)' \
194
'cat request-anonymous | git-cvsserver --export-all pserver $WORKDIR >log 2>&1 &&
195
- tail -n1 log | grep "^I LOVE YOU$"'
195
+ sed -ne \$p log | grep "^I LOVE YOU$"'
196
197
test_expect_success 'req_Root failure (export-all w/o whitelist)' \
198
'! (cat request-anonymous | git-cvsserver --export-all pserver >log 2>&1 || false)'
199
200
test_expect_success 'req_Root (everything together)' \
201
'cat request-base | git-cvsserver --export-all --strict-paths --base-path $WORKDIR/ pserver $SERVERDIR >log 2>&1 &&
202
- tail -n1 log | grep "^I LOVE YOU$"'
202
+ sed -ne \$p log | grep "^I LOVE YOU$"'
203
204
GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled true || exit 1
205