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 <git@cryptocrack.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Lukas Fleischer committed
Jul 27, 2013 at 14:11 UTC
19c3c5fdcb35b66b792534c5dc4e8d87a3952d2a
3 files changed
+7
-7
contrib/subtree/git-subtree.sh
+1
-1
@@ -311,7 +311,7 @@ copy_commit()
311
GIT_COMMITTER_NAME \
312
GIT_COMMITTER_EMAIL \
313
GIT_COMMITTER_DATE
314
- (echo -n "$annotate"; cat ) |
314
+ (printf "%s" "$annotate"; cat ) |
315
git commit-tree "$2" $3 # reads the rest of stdin
316
) || die "Can't copy commit $1"
317
}
contrib/subtree/t/t7900-subtree.sh
+4
-4
@@ -182,9 +182,9 @@ test_expect_success 'merge new subproj history into subdir' '
182
test_expect_success 'Check that prefix argument is required for split' '
183
echo "You must provide the --prefix option." > expected &&
184
test_must_fail git subtree split > actual 2>&1 &&
185
- test_debug "echo -n expected: " &&
185
+ test_debug "printf '"'"'expected: '"'"'" &&
186
test_debug "cat expected" &&
187
- test_debug "echo -n actual: " &&
187
+ test_debug "printf '"'"'actual: '"'"'" &&
188
test_debug "cat actual" &&
189
test_cmp expected actual &&
190
rm -f expected actual
@@ -193,9 +193,9 @@ test_expect_success 'Check that prefix argument is required for split' '
193
test_expect_success 'Check that the <prefix> exists for a split' '
194
echo "'"'"'non-existent-directory'"'"'" does not exist\; use "'"'"'git subtree add'"'"'" > expected &&
195
test_must_fail git subtree split --prefix=non-existent-directory > actual 2>&1 &&
196
- test_debug "echo -n expected: " &&
196
+ test_debug "printf '"'"'expected: '"'"'" &&
197
test_debug "cat expected" &&
198
- test_debug "echo -n actual: " &&
198
+ test_debug "printf '"'"'actual: '"'"'" &&
199
test_debug "cat actual" &&
200
test_cmp expected actual
201
# rm -f expected actual
t/perf/perf-lib.sh
+2
-2
@@ -160,7 +160,7 @@ test_perf () {
160
echo "$test_count" >>"$perf_results_dir"/$base.subtests
161
echo "$1" >"$perf_results_dir"/$base.$test_count.descr
162
if test -z "$verbose"; then
163
- echo -n "perf $test_count - $1:"
163
+ printf "%s" "perf $test_count - $1:"
164
else
165
echo "perf $test_count - $1:"
166
fi
@@ -169,7 +169,7 @@ test_perf () {
169
if test_run_perf_ "$2"
170
then
171
if test -z "$verbose"; then
172
- echo -n " $i"
172
+ printf " %s" "$i"
173
else
174
echo "* timing run $i/$GIT_PERF_REPEAT_COUNT:"
175
fi