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

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

Re: sed blindly eats everything beyond w command filename


From: Tapani Tarvainen
Subject: Re: sed blindly eats everything beyond w command filename
Date: 02 Mar 2001 08:32:33 +0200

address@hidden (Dan Jacobson) writes:

> sed blindly eats everything beyond w command filename.
> All the parsing rules go down the drain until newline do we part.

That is the way sed has worked since day one, and the way it
should work according to POSIX.2 as I understand it.
Semicolon is a legal character in filenames, as are {, } and space.
All commands that take filename argument (w, r, s/.../.../w)
should be terminated with a newline.

If Gnu sed would refuse filenames with semicolons it would break
existing scripts (just about anything running under VMS for example, 
or in HP-UX reading CD-ROMs mounted with version number visible).

> 0/tmp$ echo wwwww|sed 'w w;w p'
> wwwww
> 1/tmp$ ll w* 
> -rw-r--r--    1 jidanni  jidanni         6 02 27 10:36 w;w p

Exactly what I'd expect.

> OK, try the {} thingy:
> 
> 0/tmp$ echo wwwww|sed '{w w};{w p}'
> sed: -e expression #1, char 0: Unmatched `{'

Again as expected: you're writing to a file named
"w};{2 p}" and leaving your initial { unmatched.
(Incidentally, even if semicolon did terminate
filename that would not work: } must always
be preceded by newline or semicolon.)

> If this is not _bad_ then please at least document it with the w command.
> GNU sed version 3.02

I don't see anything in the man page that'd indicate semicolon should
terminate filename in 'w' or anywhere else.

It would be a good idea to document the behaviour of semicolon
properly, though.

-- 
Tapani Tarvainen



reply via email to

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