{"thread":{"id":"24190","subject":"[PATCH] t4027, t4041: Use printf instead of echo -n","startedAt":"2010-06-24T17:46:18Z","lastAt":"2010-06-25T16:26:57Z","messageCount":5,"participants":["Brian Gernhardt","Johannes Sixt","Junio C Hamano","Brandon Casey"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"144172","messageId":"1277401578-20984-1-git-send-email-brian@gernhardtsoftware.com","threadId":"24190","inReplyTo":null,"subject":"[PATCH] t4027, t4041: Use printf instead of echo -n","fromName":"Brian Gernhardt","fromEmail":"brian@gernhardtsoftware.com","sentAt":"2010-06-24T17:46:18Z","receivedAt":"2010-06-24T17:46:18Z","isPatch":true,"sender":{"key":"brian@gernhardtsoftware.com","avatar":"https://avatars.githubusercontent.com/u/133455?v=4"},"body":"BSD's echo doesn't recognize the -n option, so use printf instead\n\nSigned-off-by: Brian Gernhardt <brian@gernhardtsoftware.com>\n---\n t/t4027-diff-submodule.sh        |   10 +++++-----\n t/t4041-diff-submodule-option.sh |   14 +++++++-------\n 2 files changed, 12 insertions(+), 12 deletions(-)\n\ndiff --git a/t/t4027-diff-submodule.sh b/t/t4027-diff-submodule.sh\nindex 559b41e..ea362d3 100755\n--- a/t/t4027-diff-submodule.sh\n+++ b/t/t4027-diff-submodule.sh\n@@ -105,13 +105,13 @@ test_expect_success 'git diff HEAD with dirty submodule (work tree, refs match)'\n \texpect_from_to >expect.body $subprev $subprev-dirty &&\n \ttest_cmp expect.body actual.body &&\n \tgit diff --ignore-submodules HEAD >actual2 &&\n-\techo -n \"\" | test_cmp - actual2 &&\n+\tprintf \"\" | test_cmp - actual2 &&\n \tgit diff --ignore-submodules=untracked HEAD >actual3 &&\n \tsed -e \"1,/^@@/d\" actual3 >actual3.body &&\n \texpect_from_to >expect.body $subprev $subprev-dirty &&\n \ttest_cmp expect.body actual3.body &&\n \tgit diff --ignore-submodules=dirty HEAD >actual4 &&\n-\techo -n \"\" | test_cmp - actual4\n+\tprintf \"\" | test_cmp - actual4\n '\n test_done\n test_expect_success 'git diff HEAD with dirty submodule (index, refs match)' '\n@@ -139,11 +139,11 @@ test_expect_success 'git diff HEAD with dirty submodule (untracked, refs match)'\n \texpect_from_to >expect.body $subprev $subprev-dirty &&\n \ttest_cmp expect.body actual.body &&\n \tgit diff --ignore-submodules=all HEAD >actual2 &&\n-\techo -n \"\" | test_cmp - actual2 &&\n+\tprintf \"\" | test_cmp - actual2 &&\n \tgit diff --ignore-submodules=untracked HEAD >actual3 &&\n-\techo -n \"\" | test_cmp - actual3 &&\n+\tprintf \"\" | test_cmp - actual3 &&\n \tgit diff --ignore-submodules=dirty HEAD >actual4 &&\n-\techo -n \"\" | test_cmp - actual4\n+\tprintf \"\" | test_cmp - actual4\n '\n \n test_expect_success 'git diff (empty submodule dir)' '\ndiff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh\nindex f44b906..7600ed1 100755\n--- a/t/t4041-diff-submodule-option.sh\n+++ b/t/t4041-diff-submodule-option.sh\n@@ -207,17 +207,17 @@ EOF\n \n test_expect_success 'submodule contains untracked content (untracked ignored)' \"\n \tgit diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&\n-\techo -n '' | diff actual -\n+\tprintf '' | diff actual -\n \"\n \n test_expect_success 'submodule contains untracked content (dirty ignored)' \"\n \tgit diff-index -p --ignore-submodules=dirty --submodule=log HEAD >actual &&\n-\techo -n '' | diff actual -\n+\tprintf '' | diff actual -\n \"\n \n test_expect_success 'submodule contains untracked content (all ignored)' \"\n \tgit diff-index -p --ignore-submodules=all --submodule=log HEAD >actual &&\n-\techo -n '' | diff actual -\n+\tprintf '' | diff actual -\n \"\n \n test_expect_success 'submodule contains untracked and modifed content' \"\n@@ -240,13 +240,13 @@ EOF\n test_expect_success 'submodule contains untracked and modifed content (dirty ignored)' \"\n \techo new > sm1/foo6 &&\n \tgit diff-index -p --ignore-submodules=dirty --submodule=log HEAD >actual &&\n-\techo -n '' | diff actual -\n+\tprintf '' | diff actual -\n \"\n \n test_expect_success 'submodule contains untracked and modifed content (all ignored)' \"\n \techo new > sm1/foo6 &&\n \tgit diff-index -p --ignore-submodules --submodule=log HEAD >actual &&\n-\techo -n '' | diff actual -\n+\tprintf '' | diff actual -\n \"\n \n test_expect_success 'submodule contains modifed content' \"\n@@ -295,7 +295,7 @@ EOF\n \n test_expect_success 'modified submodule contains untracked content (all ignored)' \"\n \tgit diff-index -p --ignore-submodules=all --submodule=log HEAD >actual &&\n-\techo -n '' | diff actual -\n+\tprintf '' | diff actual -\n \"\n \n test_expect_success 'modified submodule contains untracked and modifed content' \"\n@@ -331,7 +331,7 @@ EOF\n test_expect_success 'modified submodule contains untracked and modifed content (all ignored)' \"\n \techo modification >> sm1/foo6 &&\n \tgit diff-index -p --ignore-submodules --submodule=log HEAD >actual &&\n-\techo -n '' | diff actual -\n+\tprintf '' | diff actual -\n \"\n \n test_expect_success 'modified submodule contains modifed content' \"\n-- \n1.7.1.703.g42c01\n"},{"id":"144184","messageId":"201006242134.54081.j6t@kdbg.org","threadId":"24190","inReplyTo":"1277401578-20984-1-git-send-email-brian@gernhardtsoftware.com","subject":"Re: [PATCH] t4027, t4041: Use printf instead of echo -n","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2010-06-24T19:34:53Z","receivedAt":"2010-06-24T19:34:53Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"On Donnerstag, 24. Juni 2010, Brian Gernhardt wrote:\n> BSD's echo doesn't recognize the -n option, so use printf instead\n...\n> -\techo -n \"\" | test_cmp - actual2 &&\n> +\tprintf \"\" | test_cmp - actual2 &&\n\nShouldn't you replace these by\n\n\t! test -s actual2 &&\n\n-- Hannes\n"},{"id":"144191","messageId":"1277410231-12326-1-git-send-email-brian@gernhardtsoftware.com","threadId":"24190","inReplyTo":"201006242134.54081.j6t@kdbg.org","subject":"[PATCH v2] t4027,4041: Use test -s to test for an empty file","fromName":"Brian Gernhardt","fromEmail":"brian@gernhardtsoftware.com","sentAt":"2010-06-24T20:10:31Z","receivedAt":"2010-06-24T20:10:31Z","isPatch":true,"sender":{"key":"brian@gernhardtsoftware.com","avatar":"https://avatars.githubusercontent.com/u/133455?v=4"},"body":"The tests had used a mixture of 'echo -n' (which is non-portable) and\neither test_cmp or diff to check if a file is empty.  The much easier\nand portable method to check for an empty file is '! test -s'\n\nSigned-off-by: Brian Gernhardt <brian@gernhardtsoftware.com>\n---\n\n Johannes Sixt wrote:\n > Shouldn't you replace these by\n >\n >\t! test -s actual2 &&\n\n Yes, you're right.  I was just trying to get the tests to run and didn't really pay attention to what it was trying to do.\n\n t/t4027-diff-submodule.sh        |   10 +++++-----\n t/t4041-diff-submodule-option.sh |   14 +++++++-------\n 2 files changed, 12 insertions(+), 12 deletions(-)\n\ndiff --git a/t/t4027-diff-submodule.sh b/t/t4027-diff-submodule.sh\nindex 559b41e..8f016aa 100755\n--- a/t/t4027-diff-submodule.sh\n+++ b/t/t4027-diff-submodule.sh\n@@ -105,13 +105,13 @@ test_expect_success 'git diff HEAD with dirty submodule (work tree, refs match)'\n \texpect_from_to >expect.body $subprev $subprev-dirty &&\n \ttest_cmp expect.body actual.body &&\n \tgit diff --ignore-submodules HEAD >actual2 &&\n-\techo -n \"\" | test_cmp - actual2 &&\n+\t! test -s actual2 &&\n \tgit diff --ignore-submodules=untracked HEAD >actual3 &&\n \tsed -e \"1,/^@@/d\" actual3 >actual3.body &&\n \texpect_from_to >expect.body $subprev $subprev-dirty &&\n \ttest_cmp expect.body actual3.body &&\n \tgit diff --ignore-submodules=dirty HEAD >actual4 &&\n-\techo -n \"\" | test_cmp - actual4\n+\t! test -s actual4\n '\n test_done\n test_expect_success 'git diff HEAD with dirty submodule (index, refs match)' '\n@@ -139,11 +139,11 @@ test_expect_success 'git diff HEAD with dirty submodule (untracked, refs match)'\n \texpect_from_to >expect.body $subprev $subprev-dirty &&\n \ttest_cmp expect.body actual.body &&\n \tgit diff --ignore-submodules=all HEAD >actual2 &&\n-\techo -n \"\" | test_cmp - actual2 &&\n+\t! test -s actual2 &&\n \tgit diff --ignore-submodules=untracked HEAD >actual3 &&\n-\techo -n \"\" | test_cmp - actual3 &&\n+\t! test -s actual3 &&\n \tgit diff --ignore-submodules=dirty HEAD >actual4 &&\n-\techo -n \"\" | test_cmp - actual4\n+\t! test -s actual4\n '\n \n test_expect_success 'git diff (empty submodule dir)' '\ndiff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh\nindex f44b906..db9b64d 100755\n--- a/t/t4041-diff-submodule-option.sh\n+++ b/t/t4041-diff-submodule-option.sh\n@@ -207,17 +207,17 @@ EOF\n \n test_expect_success 'submodule contains untracked content (untracked ignored)' \"\n \tgit diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&\n-\techo -n '' | diff actual -\n+\t! test -s actual -\n \"\n \n test_expect_success 'submodule contains untracked content (dirty ignored)' \"\n \tgit diff-index -p --ignore-submodules=dirty --submodule=log HEAD >actual &&\n-\techo -n '' | diff actual -\n+\t! test -s actual -\n \"\n \n test_expect_success 'submodule contains untracked content (all ignored)' \"\n \tgit diff-index -p --ignore-submodules=all --submodule=log HEAD >actual &&\n-\techo -n '' | diff actual -\n+\t! test -s actual -\n \"\n \n test_expect_success 'submodule contains untracked and modifed content' \"\n@@ -240,13 +240,13 @@ EOF\n test_expect_success 'submodule contains untracked and modifed content (dirty ignored)' \"\n \techo new > sm1/foo6 &&\n \tgit diff-index -p --ignore-submodules=dirty --submodule=log HEAD >actual &&\n-\techo -n '' | diff actual -\n+\t! test -s actual -\n \"\n \n test_expect_success 'submodule contains untracked and modifed content (all ignored)' \"\n \techo new > sm1/foo6 &&\n \tgit diff-index -p --ignore-submodules --submodule=log HEAD >actual &&\n-\techo -n '' | diff actual -\n+\t! test -s actual -\n \"\n \n test_expect_success 'submodule contains modifed content' \"\n@@ -295,7 +295,7 @@ EOF\n \n test_expect_success 'modified submodule contains untracked content (all ignored)' \"\n \tgit diff-index -p --ignore-submodules=all --submodule=log HEAD >actual &&\n-\techo -n '' | diff actual -\n+\t! test -s actual -\n \"\n \n test_expect_success 'modified submodule contains untracked and modifed content' \"\n@@ -331,7 +331,7 @@ EOF\n test_expect_success 'modified submodule contains untracked and modifed content (all ignored)' \"\n \techo modification >> sm1/foo6 &&\n \tgit diff-index -p --ignore-submodules --submodule=log HEAD >actual &&\n-\techo -n '' | diff actual -\n+\t! test -s actual -\n \"\n \n test_expect_success 'modified submodule contains modifed content' \"\n-- \n1.7.1.756.gb48b1\n"},{"id":"144207","messageId":"7vr5jwb15z.fsf@alter.siamese.dyndns.org","threadId":"24190","inReplyTo":"1277410231-12326-1-git-send-email-brian@gernhardtsoftware.com","subject":"Re: [PATCH v2] t4027,4041: Use test -s to test for an empty file","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-06-24T20:55:52Z","receivedAt":"2010-06-24T20:55:52Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Thanks.  Also the leftover \"test_done\" should be removed and the patch\nwould be perfect ;-)\n\nWill queue.  Thanks, all.\n"},{"id":"144253","messageId":"kqdYVAmM2c4O6wIC09b253C3JjQEYA9TmnkBdBwGP2ZY3QpzeGjLcA@cipher.nrlssc.navy.mil","threadId":"24190","inReplyTo":"1277410231-12326-1-git-send-email-brian@gernhardtsoftware.com","subject":"Re: [PATCH v2] t4027,4041: Use test -s to test for an empty file","fromName":"Brandon Casey","fromEmail":"brandon.casey.ctr@nrlssc.navy.mil","sentAt":"2010-06-25T16:26:57Z","receivedAt":"2010-06-25T16:26:57Z","isPatch":true,"sender":{"key":"brandon.casey.ctr@nrlssc.navy.mil","avatar":null},"body":"On 06/24/2010 03:10 PM, Brian Gernhardt wrote:\n> The tests had used a mixture of 'echo -n' (which is non-portable) and\n> either test_cmp or diff to check if a file is empty.  The much easier\n> and portable method to check for an empty file is '! test -s'\n> \n> Signed-off-by: Brian Gernhardt <brian@gernhardtsoftware.com>\n> ---\n> \n>  Johannes Sixt wrote:\n>  > Shouldn't you replace these by\n>  >\n>  >\t! test -s actual2 &&\n> \n>  Yes, you're right.  I was just trying to get the tests to run and didn't really pay attention to what it was trying to do.\n\n\nDitto.  But uh...\n\n\n> diff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh\n> index f44b906..db9b64d 100755\n> --- a/t/t4041-diff-submodule-option.sh\n> +++ b/t/t4041-diff-submodule-option.sh\n> @@ -207,17 +207,17 @@ EOF\n>  \n>  test_expect_success 'submodule contains untracked content (untracked ignored)' \"\n>  \tgit diff-index -p --ignore-submodules=untracked --submodule=log HEAD >actual &&\n> -\techo -n '' | diff actual -\n> +\t! test -s actual -\n                        ^^^\nI don't think we need the trailing dash on these.\n\n>  \"\n>  \n>  test_expect_success 'submodule contains untracked content (dirty ignored)' \"\n>  \tgit diff-index -p --ignore-submodules=dirty --submodule=log HEAD >actual &&\n> -\techo -n '' | diff actual -\n> +\t! test -s actual -\n>  \"\n>  \n>  test_expect_success 'submodule contains untracked content (all ignored)' \"\n>  \tgit diff-index -p --ignore-submodules=all --submodule=log HEAD >actual &&\n> -\techo -n '' | diff actual -\n> +\t! test -s actual -\n>  \"\n>  \n>  test_expect_success 'submodule contains untracked and modifed content' \"\n> @@ -240,13 +240,13 @@ EOF\n>  test_expect_success 'submodule contains untracked and modifed content (dirty ignored)' \"\n>  \techo new > sm1/foo6 &&\n>  \tgit diff-index -p --ignore-submodules=dirty --submodule=log HEAD >actual &&\n> -\techo -n '' | diff actual -\n> +\t! test -s actual -\n>  \"\n>  \n>  test_expect_success 'submodule contains untracked and modifed content (all ignored)' \"\n>  \techo new > sm1/foo6 &&\n>  \tgit diff-index -p --ignore-submodules --submodule=log HEAD >actual &&\n> -\techo -n '' | diff actual -\n> +\t! test -s actual -\n>  \"\n>  \n>  test_expect_success 'submodule contains modifed content' \"\n> @@ -295,7 +295,7 @@ EOF\n>  \n>  test_expect_success 'modified submodule contains untracked content (all ignored)' \"\n>  \tgit diff-index -p --ignore-submodules=all --submodule=log HEAD >actual &&\n> -\techo -n '' | diff actual -\n> +\t! test -s actual -\n>  \"\n>  \n>  test_expect_success 'modified submodule contains untracked and modifed content' \"\n> @@ -331,7 +331,7 @@ EOF\n>  test_expect_success 'modified submodule contains untracked and modifed content (all ignored)' \"\n>  \techo modification >> sm1/foo6 &&\n>  \tgit diff-index -p --ignore-submodules --submodule=log HEAD >actual &&\n> -\techo -n '' | diff actual -\n> +\t! test -s actual -\n>  \"\n>  \n>  test_expect_success 'modified submodule contains modifed content' \"\n"}]}