git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
David Aguilar <davvid@gmail.com>
Date
Apr 9, 2010, 06:04 UTC
Message-ID
<20100409060427.GA6012@gmail.com>
In-Reply-To
<1270783330-35215-1-git-send-email-brian@gernhardtsoftware.com>
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.

Show 14 quoted lines
> 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
Previous: Brian Gernhardt
Message 8 of 8 in “Makefile: Remove excess backslashes from sed”
  1. Makefile: Remove excess backslashes from sedBrian Gernhardt, Apr 9, 2010
  2. Junio C HamanoApr 9, 2010
  3. David AguilarApr 9, 2010
  4. Makefile: Avoid multi-line sed when building python scriptsDavid Aguilar, Apr 9, 2010
  5. Brian GernhardtApr 9, 2010
  6. Sverre RabbelierApr 9, 2010
  7. Makefile: Simplify handling of python scriptsBrian Gernhardt, Apr 9, 2010
  8. David AguilarApr 9, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.