Re: autoconf doesn't escape sed metacharacters in paths

2018-06-18 Thread Nick Bowler
On 6/18/18, Quasi Computational  wrote:
>  Reproduction:
>
> ```
> $ mkdir '\9'
> $ cd '\9'
> $ git clone https://github.com/haskell/network
> $ cd network
> $ git checkout 7e3f16d57b8745ef12cec8c9164bb91eeac90b5b # known-to-fail
> commit
> $ autoconf
> $ ./configure
> ```
>
> This fails for me with this line:
>
> ```
> sed: -e expression #1, char 400: invalid reference \9 on `s' command's RHS
> ```

Right, filenames containing backslashes are not supported by Autoconf,
see [1]; in particular, "These restrictions apply not only to the files
that you distribute, but also to the absolute file names of your source,
build, and destination directories."

However, I am sure if this specific issue is not too cumbersome to fix
then patches to do so would be accepted.

[1] 
https://www.gnu.org/software/autoconf/manual/autoconf.html#File-System-Conventions

Cheers,
  Nick



autoconf doesn't escape sed metacharacters in paths

2018-06-18 Thread Quasi Computational
 Reproduction:

```
$ mkdir '\9'
$ cd '\9'
$ git clone https://github.com/haskell/network
$ cd network
$ git checkout 7e3f16d57b8745ef12cec8c9164bb91eeac90b5b # known-to-fail commit
$ autoconf
$ ./configure
```

This fails for me with this line:

```
sed: -e expression #1, char 400: invalid reference \9 on `s' command's RHS
```

The offending `sed` invocation is in `config.status`, generated by
`configure` with these lines:

```
# Neutralize VPATH when `$srcdir' = `.'.
# Shell code in configure.ac might set extrasub.
# FIXME: do we really want to maintain this feature?
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_sed_extra="$ac_vpsub
$extrasub
_ACEOF
cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
:t
/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
s|@configure_input@|$ac_sed_conf_input|;t t
s&@top_builddir@&$ac_top_builddir_sub&;t t
s&@top_build_prefix@&$ac_top_build_prefix&;t t
s&@srcdir@&$ac_srcdir&;t t
s&@abs_srcdir@&$ac_abs_srcdir&;t t
s&@top_srcdir@&$ac_top_srcdir&;t t
s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t
s&@builddir@&$ac_builddir&;t t
s&@abs_builddir@&$ac_abs_builddir&;t t
s&@abs_top_builddir@&$ac_abs_top_builddir&;t t
$ac_datarootdir_hack
"
eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \
  >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5

```

`$ac_abs_srcdir` and friends contain the `\9` segment, which `sed` is
interpreting as a back-reference.

```
$ autoconf --version
autoconf (GNU Autoconf) 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+/Autoconf: GNU GPL version 3 or later
, 
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by David J. MacKenzie and Akim Demaille.
```

This bug has been tracked at
https://github.com/haskell/cabal/issues/5386 and
https://github.com/commercialhaskell/stack/issues/3944.