@matheusbsbs / matheus-bagliano / commits / 77a946be98
Fork 0

apply-one-time-sed.sh: modernize style

Convert `[ ... ]` to use `test` and test for the existence of a regular file (`-f`) instead of any file (`-e`). Move the `then`s onto their own lines so that it conforms with the general test style. Instead of redirecting input into sed, allow it to open its own input. Use `cmp -s` instead of `diff` since we only care about whether the two files are equal and `diff` is overkill for this. Signed-off-by: Denton Liu <liu.denton@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Denton Liu committed Nov 27, 2019 at 11:53 UTC 77a946be98f4cf2947f9aefac924c0ee78a042c7
1 file changed +5 -3
t/lib-httpd/apply-one-time-sed.sh
+5 -3
@@ -7,11 +7,13 @@
7 #
8 # This can be used to simulate the effects of the repository changing in
9 # between HTTP request-response pairs.
10 -if [ -e one-time-sed ]; then
10 +if test -f one-time-sed
11 +then
12 "$GIT_EXEC_PATH/git-http-backend" >out
12 - sed "$(cat one-time-sed)" <out >out_modified
13 + sed "$(cat one-time-sed)" out >out_modified
14
14 - if diff out out_modified >/dev/null; then
15 + if cmp -s out out_modified
16 + then
17 cat out
18 else
19 cat out_modified