RE: mdate-sh borks on uid/gid containing a space

2007-03-29 Thread Dave Korn
On 29 March 2007 16:27, Stepan Kasal wrote:

> Hello again,
> 
> On Thu, Mar 29, 2007 at 04:12:11PM +0100, Dave Korn wrote:
>> On 29 March 2007 15:38, Stepan Kasal wrote:
>>> On Thu, Mar 29, 2007 at 12:40:12AM +0100, Dave Korn wrote:
 On 29 March 2007 00:26, Ralf Wildenhues wrote:
>

> Eric's patch seems to indicate that line 92 needs changed, too.
> [...]
>>> So it is safer to use -n with ls /, too.
>> 
>>   Umm, yes, that's true, but not relevant; what I was pointing out is that
>> the -n gets added to the $ls_command variable, so it would already be
>> included in the command invoked on line 92, and if you take a second look
>> at the patch, you'll notice that the change to line 92 isn't about adding
>> -n, it's about taking away -l and -d.
> 
> I took a second look, and it did not help:
> 
> @@ -89,7 +93,7 @@
>  # words should be skipped to get the date.
> 
>  # On HPUX /bin/sh, "set" interprets "-rw-r--r--" as options, so the "x"
> below.
> -set x`ls -l -d /`
> +set x`$ls_command /`

  Gah, I overlooked that the original version wasn't using ls_command in the
first place.


cheers,
  DaveK
-- 
Can't think of a witty .sigline today





Re: mdate-sh borks on uid/gid containing a space

2007-03-29 Thread Stepan Kasal
Hello again,

On Thu, Mar 29, 2007 at 04:12:11PM +0100, Dave Korn wrote:
> On 29 March 2007 15:38, Stepan Kasal wrote:
> > On Thu, Mar 29, 2007 at 12:40:12AM +0100, Dave Korn wrote:
> >> On 29 March 2007 00:26, Ralf Wildenhues wrote:
> >>> 
> >>> Eric's patch seems to indicate that line 92 needs changed, too.
[...]
> > So it is safer to use -n with ls /, too.
> 
>   Umm, yes, that's true, but not relevant; what I was pointing out is that the
> -n gets added to the $ls_command variable, so it would already be included in
> the command invoked on line 92, and if you take a second look at the patch,
> you'll notice that the change to line 92 isn't about adding -n, it's about
> taking away -l and -d.

I took a second look, and it did not help:

@@ -89,7 +93,7 @@
 # words should be skipped to get the date.

 # On HPUX /bin/sh, "set" interprets "-rw-r--r--" as options, so the "x" below.
-set x`ls -l -d /`
+set x`$ls_command /`

 # Find which argument is the month.
 month=

Cheers,
Stepan




RE: mdate-sh borks on uid/gid containing a space

2007-03-29 Thread Dave Korn
On 29 March 2007 15:38, Stepan Kasal wrote:

> Hello,
> 
> On Thu, Mar 29, 2007 at 12:40:12AM +0100, Dave Korn wrote:
>> On 29 March 2007 00:26, Ralf Wildenhues wrote:
>>

>>> Eric's patch seems to indicate that line 92 needs changed, too.
>>> (I haven't tested any on w32.)
>> 
>>   I don't quite understand that myself; ISTM that having -n in $ls_command
>> should do the job for both cases.
> 
> A wild guess:
> 
> Though the current situation is this (quoting Eric):
> 
> $ \ls -ld /
> drwxrwx---+ 14 eblake Users 0 Feb  2 07:58 /
> $ \ls -lLd doc/m4.texinfo
> -rw-r--r-- 1 eblake Domain Users 221922 Mar  1 14:50 doc/m4.texinfo
> 
> it might be possible that even the user or group owner of / would
> have a blank it its name.  (With Cygwin, one never knows.)
> 
> So it is safer to use -n with ls /, too.

  Umm, yes, that's true, but not relevant; what I was pointing out is that the
-n gets added to the $ls_command variable, so it would already be included in
the command invoked on line 92, and if you take a second look at the patch,
you'll notice that the change to line 92 isn't about adding -n, it's about
taking away -l and -d.

  Ah, hang on, now I see why; those flags are /also/ already included in
$ls_command, so they're superfluous on line 92; it's just a minor tidy up.


cheers,
  DaveK
-- 
Can't think of a witty .sigline today





Re: mdate-sh borks on uid/gid containing a space

2007-03-29 Thread Stepan Kasal
Hello,

On Thu, Mar 29, 2007 at 12:40:12AM +0100, Dave Korn wrote:
> On 29 March 2007 00:26, Ralf Wildenhues wrote:
> 
> > Eric's patch seems to indicate that line 92 needs changed, too.
> > (I haven't tested any on w32.)
> 
>   I don't quite understand that myself; ISTM that having -n in $ls_command
> should do the job for both cases.

A wild guess:

Though the current situation is this (quoting Eric):

$ \ls -ld /
drwxrwx---+ 14 eblake Users 0 Feb  2 07:58 /
$ \ls -lLd doc/m4.texinfo
-rw-r--r-- 1 eblake Domain Users 221922 Mar  1 14:50 doc/m4.texinfo

it might be possible that even the user or group owner of / would
have a blank it its name.  (With Cygwin, one never knows.)

So it is safer to use -n with ls /, too.

Just guessing, I'm not a Cygwin user.

Stepan Kasal




RE: mdate-sh borks on uid/gid containing a space

2007-03-28 Thread Dave Korn
On 29 March 2007 00:26, Ralf Wildenhues wrote:

> Hi Dave,
> 
> * Dave Korn wrote on Wed, Mar 28, 2007 at 07:01:59PM CEST:
>> 
>>   As the subject line says, mdate-sh can get badly confused if there are
>> spaces in the textual version of the uid or gid.
> 
> Yep:
>

> Eric's patch seems to indicate that line 92 needs changed, too.
> (I haven't tested any on w32.)

  I don't quite understand that myself; ISTM that having -n in $ls_command
should do the job for both cases.
 
> It would surely be helpful to know whether we can assume -n to work
> portably and avoid the test (we test for -L which is POSIX, too).

  Well, to be fair it's a lot safer to test for it, and since this script may
only be invoked once in a very rare while, I don't suppose it's that important
to optimise every last bit out of it.  I'd like to hear Eric's rationale about
the line 92 change, but I reckon his patch is probably safer.

  He remembered to update the scriptversion and copyright lines, too!  :)

cheers,
  DaveK
-- 
Can't think of a witty .sigline today





Re: mdate-sh borks on uid/gid containing a space

2007-03-28 Thread Ralf Wildenhues
Hi Dave,

* Dave Korn wrote on Wed, Mar 28, 2007 at 07:01:59PM CEST:
> 
>   As the subject line says, mdate-sh can get badly confused if there are
> spaces in the textual version of the uid or gid.

Yep:

Eric's patch seems to indicate that line 92 needs changed, too.
(I haven't tested any on w32.)

It would surely be helpful to know whether we can assume -n to work
portably and avoid the test (we test for -L which is POSIX, too).

Cheers,
Ralf




mdate-sh borks on uid/gid containing a space

2007-03-28 Thread Dave Korn


Afternoon all,

  As the subject line says, mdate-sh can get badly confused if there are
spaces in the textual version of the uid or gid.  I don't know how often this
happens on real unix systems, but it's a very common occurrence on Cygwin
systems, causing this:

/src/nongnu/remake-3.80+dbg-0.61/config $ . ./mdate-sh  ../doc/stamp-vti
Users March Mar

because the output from ls -l looks like this:

/src/nongnu/remake-3.80+dbg-0.61/config $ ls -la ../doc/stamp-vti
-rw-r--r-- 1 dk Domain Users 136 Mar 22 16:37 ../doc/stamp-vti

for some files, and like this:

/src/nongnu/remake-3.80+dbg-0.61/config $ ls -l -L -d /
drwxrwx---+ 42 dk Users 0 Mar 27 15:34 /

for others, and so the number of 'shift ;' commands to concatenate into the
'command' variable can be out by one.

  The attached patch adds '-n' to the ls commands in mdate-sh, forcing the uid
and gid to be printed as numeric values instead of textual names.  Since we're
only discarding them anyway this is the simplest way of guaranteeing they have
no embedded spaces.

  The '-n' flag is mandated by the opengroup posix spec for 'ls', but other
than that I don't know how portable it is or is not.  The patch is against a
copy of mdate-sh I found in a tarball of 'remake', but I've verified the same
problem still exists in cvs HEAD.


2007-03-28  Dave Korn  <[EMAIL PROTECTED]>

* lib/mdate-sh:  Add '-n' switch to 'ls' invocation to avoid parsing
error when uid or gid field contain spaces in textual representation.


cheers,
  DaveK

[*] - http://www.opengroup.org/onlinepubs/009695399/utilities/ls.html
-- 
Can't think of a witty .sigline today


automake-mdate-space-bug-patch.diff
Description: Binary data