Download raw body.
regress/cmdline/diff.sh portability fixes
On Sat, Nov 28, 2020 at 05:45:53PM +0100, Christian Weisgerber wrote: > The diff.sh regression test failures on FreeBSD are due to portability > problems in the shell code of the test. > > Replace echo with printf, stop option processing with "--" for portability > > OpenBSD sh's built-in echo parses System-V-style backslash escapes, > but traditional BSD echo(1) doesn't, so "\\" is interpreted > differently. > > FreeBSD's printf(1) does getopt(3) option processing despite not > accepting any options. bash(1) has even added an option to its > built-in printf. *sigh* So terminate option processing with "--" > before passing a format string that starts with "-". Ugh, this is a bit annoying. I am sure such portability problems will be reintroduced at some point. Nobody can keep such quirks in mind all the time. Perhaps we should use "here documents" more often to avoid this? > ok? Fine with me. > > diff 9a1d514689bb6e57bb47e4c13630ba38bd650a39 /home/naddy/got > blob - 883be7a1fb5bdd2de7ed9df74a676c22d4a2c869 > file + regress/cmdline/diff.sh > --- regress/cmdline/diff.sh > +++ regress/cmdline/diff.sh > @@ -619,7 +619,7 @@ test_diff_binary_files() { > echo '+++ foo' >> $testroot/stdout.expected > echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected > printf '+\377\377\0\0\377\377\0\0\n' >> $testroot/stdout.expected > - echo '\\ No newline at end of file' >> $testroot/stdout.expected > + printf '\\ No newline at end of file\n' >> $testroot/stdout.expected > > (cd $testroot/wt && got diff -a > $testroot/stdout) > cmp -s $testroot/stdout.expected $testroot/stdout > @@ -643,10 +643,10 @@ test_diff_binary_files() { > echo '--- foo' >> $testroot/stdout.expected > echo '+++ foo' >> $testroot/stdout.expected > echo '@@ -1 +1 @@' >> $testroot/stdout.expected > - printf '-\377\377\0\0\377\377\0\0\n' >> $testroot/stdout.expected > - echo '\\ No newline at end of file' >> $testroot/stdout.expected > + printf -- '-\377\377\0\0\377\377\0\0\n' >> $testroot/stdout.expected > + printf '\\ No newline at end of file\n' >> $testroot/stdout.expected > printf '+\377\200\0\0\377\200\0\0\n' >> $testroot/stdout.expected > - echo '\\ No newline at end of file' >> $testroot/stdout.expected > + printf '\\ No newline at end of file\n' >> $testroot/stdout.expected > > (cd $testroot/wt && got diff -a > $testroot/stdout) > cmp -s $testroot/stdout.expected $testroot/stdout > -- > Christian "naddy" Weisgerber naddy@mips.inka.de > >
regress/cmdline/diff.sh portability fixes