automake-patches
[Top][All Lists]
Advanced

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

Re: ylwrap issues


From: Tim Van Holder
Subject: Re: ylwrap issues
Date: Sun, 17 Jun 2001 22:26:24 +0200

> > I must say that
> >     sed -e 's,\\\,\\\\\\\,g'
> > looked like it had too many backslashes; but with just
> >     sed -e 's,\\,\\\\,g'
> > sed complains about an unterminated expression.
>
> What if you add one more backslash, so that they come in even numbers?
> Without this, you'll be quoting the comma at some point, and it is
> quite likely that some sed will barf on it.

Hmm - thought I tried that and had it fail.

However, this test script proves me wrong:

#! /bin/sh

testpath='C:\Windows\Evil\666.doc'

echo "Direct(1) (most logical)"
echo "$testpath" |sed -e 's,\\,\\\\,g'
echo "Direct(2) (doubled backslashes)"
echo "$testpath" |sed -e 's,\\\\,\\\\\\\\,g'
echo "Direct(3) (can't work, can it?)"
echo "$testpath" |sed -e 's,\\\,\\\\\\\,g'

echo "Indirect(1) (most logical)"
echo `echo "$testpath" |sed -e 's,\\,\\\\,g'`
echo "Indirect(2) (doubled backslashes)"
echo `echo "$testpath" |sed -e 's,\\\\,\\\\\\\\,g'`
echo "Indirect(3) (can't work, can it?)"
echo `echo "$testpath" |sed -e 's,\\\,\\\\\\\,g'`


This yields:

Direct(1) (most logical)
C:\\Windows\\Evil\\666.doc
Direct(2) (doubled backslashes)
C:\Windows\Evil\666.doc
Direct(3) (can't work, can it?)
sed.exe: -e expression #1, char 15: Unterminated `s' command
Indirect(1) (most logical)
sed.exe: -e expression #1, char 8: Unterminated `s' command

Indirect(2) (doubled backslashes)
C:\\Windows\\Evil\\666.doc
Indirect(3) (can't work, can it?)
C:\\Windows\\Evil\\666.doc

So indeed, doubling up does work.

Amended patch follows:

Index: lib/ylwrap
===================================================================
RCS file: /cvs/automake/automake/lib/ylwrap,v
retrieving revision 1.16
diff -u -u -r1.16 ylwrap
--- lib/ylwrap  2001/05/15 03:33:20     1.16
+++ lib/ylwrap  2001/06/17 20:21:59
@@ -31,8 +31,8 @@
 shift
 # Make any relative path in $prog absolute.
 case "$prog" in
- /* | [A-Za-z]:*) ;;
- */*) prog="`pwd`/$prog" ;;
+ [\\/]* | ?:[\\/]*) ;;
+ *[\\/]*) prog="`pwd`/$prog" ;;
 esac

 # We also have to accept options here and append them to the program.
@@ -54,7 +54,7 @@
 input="$1"
 shift
 case "$input" in
- /* | [A-Za-z]:*)
+ [\\/]* | ?:[\\/]*)
     # Absolute path; do nothing.
     ;;
  *)
@@ -64,10 +64,11 @@
 esac

 # The directory holding the input.
-input_dir="`echo $input | sed -e 's,/[^/]*$,,'`"
+input_dir=`echo "$input" | sed -e 's,\([\\/]\)[^\\/]*$,\1,'`
+
 # Quote $INPUT_DIR so we can use it in a regexp.
-# FIXME: really we should care about more than `.'.
-input_rx="`echo $input_dir | sed -e 's,\.,\\\.,g'`"
+# FIXME: really we should care about more than `.' and `\'.
+input_rx=`echo "$input_dir" | sed -e 's,\\\\,\\\\\\\\,g' -e
's,\\.,\\\\.,g'`

 echo "got $input_rx"

@@ -120,7 +121,7 @@
          # If $2 is an absolute path name, then just use that,
          # otherwise prepend `../'.
          case "$2" in
-          /* | [A-Za-z]:*) target="$2";;
+          [\\/]* | ?:[\\/]*) target="$2";;
           *) target="../$2";;
         esac





reply via email to

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