1
0
mirror of https://github.com/git/git.git synced 2024-10-03 16:22:22 +02:00
Commit Graph

2 Commits

Author SHA1 Message Date
Jeff King
40a7ce64e1 tr portability fixes
Specifying character ranges in tr differs between System V
and POSIX. In System V, brackets are required (e.g.,
'[A-Z]'), whereas in POSIX they are not.

We can mostly get around this by just using the bracket form
for both sets, as in:

  tr '[A-Z] '[a-z]'

in which case POSIX interpets this as "'[' becomes '['",
which is OK.

However, this doesn't work with multiple sequences, like:

  # rot13
  tr '[A-Z][a-z]' '[N-Z][A-M][n-z][a-m]'

where the POSIX version does not behave the same as the
System V version. In this case, we must simply enumerate the
sequence.

This patch fixes problematic uses of tr in git scripts and
test scripts in one of three ways:

  - if a single sequence, make sure it uses brackets
  - if multiple sequences, enumerate
  - if extra brackets (e.g., tr '[A]' 'a'), eliminate
    brackets

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-03-12 21:10:00 -07:00
Junio C Hamano
f8b6809d52 Fix "quote" misconversion for rewrite diff output.
663af3422a648e87945e4d8c0cc3e13671f2bbde (Full rework of
quote_c_style and write_name_quoted.) mistakenly used puts()
when writing out a fixed string when it did not want to add a
terminating LF.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-21 23:06:44 -08:00