Bug#207391: glibc: csu/Makefile patch
Colin Watson <cjwatson@debian.org> wrote:
<snip>
> On Mon, Sep 15, 2003 at 01:58:18PM -0700, Eric Wong wrote:
> > Package: glibc
> > Version: 2.3.7-2; reported 2003-09-15
> > Followup-For: Bug #207391
> >
> > I've gotten this newline issue in version-info.h both while building from
> > non-modified sources for i386 and my own modified sources for i686.
> >
> > I'm not sure if it's a bug in make in the way it passes the argument, a bug in
> > echo in coreutils or a shell bug.
> >
> > The \\n\" sequence used in this section of the Makefile causes the newline
> > character to be interpreted, instead of the double backslash being interpreted
> > as a one. The below patch works around the problem. I'm using the latest
> > versions of all the build-dependencies from unstable.
> >
> > Below is a patch that works around the buggy \\n\" handling. Should be a
> > harmless fix even on systems that don't have the bug.
>
> This points straight at differences in the echo builtin between shells.
> POSIX notes: "It is not possible to use echo portably across all POSIX
> systems unless both -n (as the first argument) and escape sequences are
> omitted." I bet your /bin/sh isn't bash: for instance, dash's echo
> interprets its arguments in the way you describe. Zed, is the same true
> for you?
Yup, I learned of dash last week and upon seeing the words 'smaller' and
'faster' in the description, I immediately installed it on this system
as my /bin/sh being the performance nut I am :)
I wonder how many other source packages are affected by this discrepancy
or others like it, hopefully not a lot
> If you need any escape sequences in a portable shell script, then the
> only real option is to avoid echo altogether and use printf instead. I'd
> suggest the following modifications in place of yours:
>
> > --- glibc-2.3.2.o/glibc-2.3.2/csu/Makefile 2003-09-15 13:35:41.000000000 -0700
> > +++ glibc-2.3.2/glibc-2.3.2/csu/Makefile 2003-09-15 13:34:21.000000000 -0700
> > @@ -231,13 +231,15 @@
> > if [ -z "$$os" ]; then \
> > os=Linux; \
> > fi; \
> > - echo "\"Compiled on a $$os $$version system" \
> > - "on `date +%Y-%m-%d`.\\n\"" ;; \
> > + echo -n "\"Compiled on a $$os $$version system" \
> > + "on `date +%Y-%m-%d`.\\" ; \
> > + echo "n\"";; \
>
> + printf '"Compiled on a %s %s system on %s.\\n"\n' \
> + "$os" "$version" "`date +%Y-%m-%d`" ;; \
this should be: "$$os" "$$version"
<snip>
> (Sorry I haven't had time to construct a proper patch, but this should
> get the gist across.)
This new patch (using printf) works for me:
--- glibc-2.3.2.orig/glibc-2.3.2/csu/Makefile 2003-09-15 20:04:17.000000000 -0700
+++ glibc-2.3.2.new/glibc-2.3.2/csu/Makefile 2003-09-15 20:03:51.000000000 -0700
@@ -231,13 +231,13 @@
if [ -z "$$os" ]; then \
os=Linux; \
fi; \
- echo "\"Compiled on a $$os $$version system" \
- "on `date +%Y-%m-%d`.\\n\"" ;; \
+ printf '"Compiled on a %s %s system on %s.\\n"\n' \
+ "$$os" "$$version" "`date +%Y-%m-%d`" ;; \
*) ;; \
esac; \
files="$(all-Banner-files)"; \
if test -n "$$files"; then \
- echo "\"Available extensions:\\n\""; \
+ printf '"Available extensions:\\n"\n'; \
sed -e '/^#/d' -e 's/^[[:space:]]*/ /' \
-e 's/\(^.*$$\)/\"\1\\n\"/' $$files; \
fi) > $@T
--
Eric Wong
Reply to: