bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bug#99807: diff doesn't handle filenames with spaces (fwd)


From: Paul Eggert
Subject: Re: Bug#99807: diff doesn't handle filenames with spaces (fwd)
Date: Mon, 4 Jun 2001 12:47:00 -0700 (PDT)

> Date: Mon, 4 Jun 2001 15:06:30 +0200 (CEST)
> From: Santiago Vila <address@hidden>
> 
> I have received this (surprising) report from the Debian Bug System.
> Is this considered as a bug?

It is not a bug, since neither POSIX nor the current diff or patch
documentation requires support for arbitrary file names.  diff and
patch do work correctly on all portable POSIX file names.

However, there should be a quoting convention for arbitrary file
names, including file names containing spaces, newlines, and other
control characters.  The quoting convention should be upward
compatible with the currently documented behavior, so it shouldn't
affect portable POSIX file names.

> Note, the generate diff doesn't differentiate that internal space.

Actually, it does differentiate, because it uses tab after the file
name, not space.  I think 'patch' should use the tab if it finds one,
and should fall back on using space only if the line does not contain
any tabs.  Of course that won't handle file names containing tabs (or
newlines), but these are less common.

One possibility to handle the problem in general is to adopt the
'shell' quoting style of GNU ls.  This is upward compatible with
POSIX.  E.g.:

$ newline='
'
$ for i in 'ab' 'a b' "a${newline}b" a\'b; do echo "$i" >$i; done
$ for i in 'ab' 'a b' "a${newline}b" a\'b; do diff -u /dev/null "$i"; done
--- /dev/null   Mon Jun  4 12:20:30 2001
+++ ab  Mon Jun  4 12:39:07 2001
@@ -0,0 +1 @@
+ab
--- /dev/null   Mon Jun  4 12:20:30 2001
+++ 'a b'       Mon Jun  4 12:39:07 2001
@@ -0,0 +1 @@
+a b
--- /dev/null   Mon Jun  4 12:20:30 2001
+++ 'a
b'      Mon Jun  4 12:39:07 2001
@@ -0,0 +1,2 @@
+a
+b
--- /dev/null   Mon Jun  4 12:20:30 2001
+++ 'a'\''b' Mon Jun  4 12:39:07 2001
@@ -0,0 +1 @@
+a'b



reply via email to

[Prev in Thread] Current Thread [Next in Thread]