Subject: bin/2748: [dM] make manpage mis-describes $(:S///g)
To: None <gnats-bugs@gnats.netbsd.org>
From: der Mouse <mouse@Rodents.Montreal.QC.CA>
List: netbsd-bugs
Date: 09/12/1996 19:00:41
>Number: 2748
>Category: bin
>Synopsis: [dM] make manpage mis-describes $(:S///g)
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: bin-bug-people (Utility Bug People)
>State: open
>Class: doc-bug
>Submitter-Id: net
>Arrival-Date: Thu Sep 12 16:05:00 1996
>Last-Modified:
>Originator: der Mouse
>Organization:
Dis-
>Release: 1.2_BETA
>Environment:
Any (noticed on Sun-3/260)
>Description:
The make(1) manpage, in describing the :S modifier to a
variable expansion, says
S/old_pattern/new_pattern/[g]
Modify the first occurrence of old_pattern in each
word to be replaced with new_pattern. If a `g' is ap-
pended to the last slash of the pattern, all occur-
rences in each word are replaced.
This is not the behavior I see. What I see is more like
S/old_pattern/new_pattern/[g]
Modify the first occurrence of old_pattern,
replacing it with new_pattern. If a `g' is
appended to the last slash of the pattern, all
occurrences in each word are replaced.
There does not appear to be any way to get the behavior the
manpage claims the without-g form provides.
>How-To-Repeat:
% cat Makefile
VAR = x-foo-bar-foo-bar-x y-foo-two-bar-foo-two-bar-y
.PHONY: foo
foo:
@echo VAR = $(VAR)
@echo :S/foo/X/ = $(VAR:S/foo/X/)
@echo :S/foo/X/g = $(VAR:S/foo/X/g)
@echo :S/two/X/ = $(VAR:S/two/X/)
@echo :S/two/X/g = $(VAR:S/two/X/g)
% make
VAR = x-foo-bar-foo-bar-x y-foo-two-bar-foo-two-bar-y
:S/foo/X/ = x-X-bar-foo-bar-x y-foo-two-bar-foo-two-bar-y
:S/foo/X/g = x-X-bar-X-bar-x y-X-two-bar-X-two-bar-y
:S/two/X/ = x-foo-bar-foo-bar-x y-foo-X-bar-foo-two-bar-y
:S/two/X/g = x-foo-bar-foo-bar-x y-foo-X-bar-foo-X-bar-y
%
Note that no "foo"s in the second word were changed by the
first substitution.
>Fix:
I have classified this as a doc-bug, and as such, the correct
fix would be to rewrite the relevant section of the manpage.
However, I would much prefer to completely replace the :S code,
since it has other problems; most notably, it does not support
regexps, though it supports ^ and $ as special cases - regexps
would be _extremely_ useful, and since we've got most of the
necessary regex support in libc, it would be pretty easy. (The
only thing that's missing in libc, as far as I can tell, is
some routine to automatically handle \1, \2, &, etc
substitutions in a replacement string.)
I hope to get this code written soon; if and when I do, I'll
send it in as an addendum to this PR, though as far as I can
tell there's no way for me to reclassify it as a change-request
when I do. (Do people actually _use_ the Class: values? :-)
der Mouse
mouse@rodents.montreal.qc.ca
01 EE 31 F6 BB 0C 34 36 00 F3 7C 5A C1 A0 67 1D
>Audit-Trail:
>Unformatted: