Skip to content

Commit a7f0fcb

Browse files
committed
Merge branch 'bb/sh-scripts-cleanup'
Shell scripts clean-up. * bb/sh-scripts-cleanup: (22 commits) git-quiltimport: avoid an unnecessary subshell contrib/coverage-diff: avoid redundant pipelines t/t9*: merge "grep | sed" pipelines t/t8*: merge "grep | sed" pipelines t/t5*: merge a "grep | sed" pipeline t/t4*: merge a "grep | sed" pipeline t/t3*: merge a "grep | awk" pipeline t/t1*: merge a "grep | sed" pipeline t/t9*: avoid redundant uses of cat t/t8*: avoid redundant use of cat t/t7*: avoid redundant use of cat t/t6*: avoid redundant uses of cat t/t5*: avoid redundant uses of cat t/t4*: avoid redundant uses of cat t/t3*: avoid redundant uses of cat t/t1*: avoid redundant uses of cat t/t0*: avoid redundant uses of cat t/perf: avoid redundant use of cat t/annotate-tests.sh: avoid redundant use of cat t/lib-cvs.sh: avoid redundant use of cat ...
2 parents 46d8bf3 + c2a7536 commit a7f0fcb

37 files changed

+85
-97
lines changed

Documentation/howto/update-hook-example.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ info "The user is: '$username'"
100100

101101
if test -f "$allowed_users_file"
102102
then
103-
rc=$(cat $allowed_users_file | grep -v '^#' | grep -v '^$' |
103+
rc=$(grep -Ev '^(#|$)' $allowed_users_file |
104104
while read heads user_patterns
105105
do
106106
# does this rule apply to us?
@@ -138,7 +138,7 @@ info "'$groups'"
138138

139139
if test -f "$allowed_groups_file"
140140
then
141-
rc=$(cat $allowed_groups_file | grep -v '^#' | grep -v '^$' |
141+
rc=$(grep -Ev '^(#|$)' $allowed_groups_file |
142142
while read heads group_patterns
143143
do
144144
# does this rule apply to us?

contrib/coverage-diff.sh

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,7 @@ do
7474
sort >uncovered_lines.txt
7575

7676
comm -12 uncovered_lines.txt new_lines.txt |
77-
sed -e 's/$/\)/' |
78-
sed -e 's/^/ /' >uncovered_new_lines.txt
77+
sed -e 's/$/\)/' -e 's/^/ /' >uncovered_new_lines.txt
7978

8079
grep -q '[^[:space:]]' <uncovered_new_lines.txt &&
8180
echo $file >>coverage-data.txt &&
@@ -91,11 +90,7 @@ cat coverage-data.txt
9190

9291
echo "Commits introducing uncovered code:"
9392

94-
commit_list=$(cat coverage-data.txt |
95-
grep -E '^[0-9a-f]{7,} ' |
96-
awk '{print $1;}' |
97-
sort |
98-
uniq)
93+
commit_list=$(awk '/^[0-9a-f]{7,}/ { print $1 }' coverage-data.txt | sort -u)
9994

10095
(
10196
for commit in $commit_list

contrib/subtree/t/t7900-subtree.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ test_create_pre2_32_repo () {
6363
git -C "$1" log -1 --format=%B HEAD^2 >msg &&
6464
test_commit -C "$1-sub" --annotate sub2 &&
6565
git clone --no-local "$1" "$1-clone" &&
66-
new_commit=$(cat msg | sed -e "s/$commit/$tag/" | git -C "$1-clone" commit-tree HEAD^2^{tree}) &&
66+
new_commit=$(sed -e "s/$commit/$tag/" msg | git -C "$1-clone" commit-tree HEAD^2^{tree}) &&
6767
git -C "$1-clone" replace HEAD^2 $new_commit
6868
}
6969

git-quiltimport.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ do
148148
if [ -z "$dry_run" ] ; then
149149
git apply --index -C1 ${level:+"$level"} "$tmp_patch" &&
150150
tree=$(git write-tree) &&
151-
commit=$( (echo "$SUBJECT"; echo; cat "$tmp_msg") | git commit-tree $tree -p $commit) &&
151+
commit=$( { echo "$SUBJECT"; echo; cat "$tmp_msg"; } | git commit-tree $tree -p $commit) &&
152152
git update-ref -m "quiltimport: $patch_name" HEAD $commit || exit 4
153153
fi
154154
done 3<"$QUILT_SERIES"

t/annotate-tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ test_expect_success 'blame -L :funcname with userdiff driver' '
532532
"$(cat file.template)" &&
533533
test_commit --author "B <[email protected]>" \
534534
"change" "$fortran_file" \
535-
"$(cat file.template | sed -e s/ChangeMe/IWasChanged/)" &&
535+
"$(sed -e s/ChangeMe/IWasChanged/ file.template)" &&
536536
check_count -f "$fortran_file" -L:RIGHT A 3 B 1
537537
'
538538

t/lib-cvs.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ test_cmp_branch_tree () {
7171
find . -type d -name .git -prune -o -type f -print
7272
) | sort >module-git-"$1".list &&
7373
test_cmp module-cvs-"$1".list module-git-"$1".list &&
74-
cat module-cvs-"$1".list | while read f
74+
while read f
7575
do
7676
test_cmp_branch_file "$1" "$f" || return 1
77-
done
77+
done <module-cvs-"$1".list
7878
}

t/perf/repos/inflate-repo.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ do
3333
done
3434

3535
git ls-tree -r HEAD >GEN_src_list
36-
nr_src_files=$(cat GEN_src_list | wc -l)
36+
nr_src_files=$(wc -l <GEN_src_list)
3737

3838
src_branch=$(git symbolic-ref --short HEAD)
3939

t/t0002-gitfile.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ test_expect_success 'final setup + check rev-parse --git-dir' '
4040

4141
test_expect_success 'check hash-object' '
4242
echo "foo" >bar &&
43-
SHA=$(cat bar | git hash-object -w --stdin) &&
43+
SHA=$(git hash-object -w --stdin <bar) &&
4444
test_path_is_file "$REAL/objects/$(objpath $SHA)"
4545
'
4646

t/t0011-hashmap.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ test_expect_success 'grow / shrink' '
239239
echo value40 >> expect &&
240240
echo size >> in &&
241241
echo 64 39 >> expect &&
242-
cat in | test-tool hashmap > out &&
242+
test-tool hashmap <in >out &&
243243
test_cmp expect out
244244
245245
'

t/t0028-working-tree-encoding.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ do
131131
test_when_finished "rm -f crlf.utf${i}.raw lf.utf${i}.raw" &&
132132
test_when_finished "git reset --hard HEAD^" &&
133133
134-
cat lf.utf8.raw | write_utf${i} >lf.utf${i}.raw &&
135-
cat crlf.utf8.raw | write_utf${i} >crlf.utf${i}.raw &&
134+
write_utf${i} <lf.utf8.raw >lf.utf${i}.raw &&
135+
write_utf${i} <crlf.utf8.raw >crlf.utf${i}.raw &&
136136
cp crlf.utf${i}.raw eol.utf${i} &&
137137
138138
cat >expectIndexLF <<-EOF &&

0 commit comments

Comments
 (0)