Subject: Re: [PATCH] Makefile: Remove excess backslashes from sed

From: David Aguilar <[email-masked]>
Date: Thu, 8 Apr 2010 23:04:28 -0700

On Thu, Apr 08, 2010 at 11:22:10PM -0400, Brian Gernhardt wrote:
> The sed script that was intended to add lines altering the sys.path
> had extra backslashes in them.  Instead resulting [snip]
>   import sys; \ import os; \ sys.path.insert( ... )

On linux sed I get (or I was dreaming when I tried it):

import sys; \
	import os; \
	sys.path.insert(0, os.getenv(foo,
	                             bar))

We should instead smash it all into one line instead to
avoid differences in sed behavior:

import sys; import os; sys.path.insert(0, os.getenv(foo,
                                                    bar))

If that's what it is, then your patch would produce this on
linux:

import sys;
	import os;
	sys.path.insert(foo,
	                bar)

...which is invalid syntax.

So let's smash it all onto one line instead.  That way I don't
have to think about or test whether there's any difference in
how sed handles newlines.  It'll be the Obviously Correct(tm)
sol'n.  Or maybe I was dreaming?

If you don't beat me to it by the tomorrow night I'll try and
throw together a patch.  Thanks for catching this.

> diff --git a/Makefile b/Makefile
> index f0fe351..b9eb1ca 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -1632,8 +1632,8 @@ $(patsubst %.py,%,$(SCRIPT_PYTHON)): % : %.py
>  	sed -e '1{' \
>  	    -e '	s|#!.*python|#!$(PYTHON_PATH_SQ)|' \
>  	    -e '}' \
> -	    -e 's|^import sys.*|&; \\\
> -	           import os; \\\
> +	    -e 's|^import sys.*|&; \
> +	           import os; \
>  	           sys.path.insert(0, os.getenv("GITPYTHONLIB",\
>  	                                        "@@INSTLIBDIR@@"));|' \
-- 

	David