Skip to content

Commit 19c3c5f

Browse files
Lukas Fleischergitster
authored andcommitted
Avoid using echo -n anywhere
`echo -n` is non-portable. The POSIX specification says: Conforming applications that wish to do prompting without <newline> characters or that could possibly be expecting to echo a -n, should use the printf utility derived from the Ninth Edition system. Since all of the affected shell scripts use a POSIX shell shebang, replace `echo -n` invocations with printf. Signed-off-by: Lukas Fleischer <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f59bebb commit 19c3c5f

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

contrib/subtree/git-subtree.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ copy_commit()
311311
GIT_COMMITTER_NAME \
312312
GIT_COMMITTER_EMAIL \
313313
GIT_COMMITTER_DATE
314-
(echo -n "$annotate"; cat ) |
314+
(printf "%s" "$annotate"; cat ) |
315315
git commit-tree "$2" $3 # reads the rest of stdin
316316
) || die "Can't copy commit $1"
317317
}

contrib/subtree/t/t7900-subtree.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,9 @@ test_expect_success 'merge new subproj history into subdir' '
182182
test_expect_success 'Check that prefix argument is required for split' '
183183
echo "You must provide the --prefix option." > expected &&
184184
test_must_fail git subtree split > actual 2>&1 &&
185-
test_debug "echo -n expected: " &&
185+
test_debug "printf '"'"'expected: '"'"'" &&
186186
test_debug "cat expected" &&
187-
test_debug "echo -n actual: " &&
187+
test_debug "printf '"'"'actual: '"'"'" &&
188188
test_debug "cat actual" &&
189189
test_cmp expected actual &&
190190
rm -f expected actual
@@ -193,9 +193,9 @@ test_expect_success 'Check that prefix argument is required for split' '
193193
test_expect_success 'Check that the <prefix> exists for a split' '
194194
echo "'"'"'non-existent-directory'"'"'" does not exist\; use "'"'"'git subtree add'"'"'" > expected &&
195195
test_must_fail git subtree split --prefix=non-existent-directory > actual 2>&1 &&
196-
test_debug "echo -n expected: " &&
196+
test_debug "printf '"'"'expected: '"'"'" &&
197197
test_debug "cat expected" &&
198-
test_debug "echo -n actual: " &&
198+
test_debug "printf '"'"'actual: '"'"'" &&
199199
test_debug "cat actual" &&
200200
test_cmp expected actual
201201
# rm -f expected actual

t/perf/perf-lib.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ test_perf () {
160160
echo "$test_count" >>"$perf_results_dir"/$base.subtests
161161
echo "$1" >"$perf_results_dir"/$base.$test_count.descr
162162
if test -z "$verbose"; then
163-
echo -n "perf $test_count - $1:"
163+
printf "%s" "perf $test_count - $1:"
164164
else
165165
echo "perf $test_count - $1:"
166166
fi
@@ -169,7 +169,7 @@ test_perf () {
169169
if test_run_perf_ "$2"
170170
then
171171
if test -z "$verbose"; then
172-
echo -n " $i"
172+
printf " %s" "$i"
173173
else
174174
echo "* timing run $i/$GIT_PERF_REPEAT_COUNT:"
175175
fi

0 commit comments

Comments
 (0)