[pypy-commit] pypy default: Replace '$$' with '%d'. It is very confusing to use

arigo noreply at buildbot.pypy.org
Sun Nov 15 17:52:34 EST 2015


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r80696:76f932bfa900
Date: 2015-11-15 22:56 +0000
http://bitbucket.org/pypy/pypy/changeset/76f932bfa900/

Log:	Replace '$$' with '%d'. It is very confusing to use
	'PYPYLOG=jit:log.$$' in bash, because bash itself replaces the $$
	with the pid of the bash process.

diff --git a/rpython/translator/c/src/debug_print.c b/rpython/translator/c/src/debug_print.c
--- a/rpython/translator/c/src/debug_print.c
+++ b/rpython/translator/c/src/debug_print.c
@@ -30,7 +30,7 @@
 
   if (filename && filename[0])
     {
-      char *newfilename = NULL, *doubledollar;
+      char *newfilename = NULL, *escape;
       char *colon = strchr(filename, ':');
       if (filename[0] == '+')
         {
@@ -52,17 +52,17 @@
           debug_prefix[n] = '\0';
           filename = colon + 1;
         }
-      doubledollar = strstr(filename, "$$");
-      if (doubledollar)  /* a "$$" in the filename is replaced with the pid */
+      escape = strstr(filename, "%d");
+      if (escape)  /* a "%d" in the filename is replaced with the pid */
         {
           newfilename = malloc(strlen(filename) + 32);
           if (newfilename != NULL)
             {
               char *p = newfilename;
-              memcpy(p, filename, doubledollar - filename);
-              p += doubledollar - filename;
+              memcpy(p, filename, escape - filename);
+              p += escape - filename;
               sprintf(p, "%ld", (long)getpid());
-              strcat(p, doubledollar + 2);
+              strcat(p, escape + 2);
               filename = newfilename;
             }
         }
@@ -71,7 +71,7 @@
           pypy_debug_file = fopen(filename, "w");
         }
 
-      if (doubledollar)
+      if (escape)
         {
           free(newfilename);   /* if not null */
           /* the env var is kept and passed to subprocesses */
@@ -125,7 +125,7 @@
     {
       fclose(pypy_debug_file);
       pypy_debug_file = NULL;
-      /* if PYPYLOG was set to a name with "$$" in it, it is still
+      /* if PYPYLOG was set to a name with "%d" in it, it is still
          alive, and will be reopened with the new subprocess' pid as
          soon as it logs anything */
       debug_ready = 0;
diff --git a/rpython/translator/c/src/debug_print.h b/rpython/translator/c/src/debug_print.h
--- a/rpython/translator/c/src/debug_print.h
+++ b/rpython/translator/c/src/debug_print.h
@@ -21,9 +21,9 @@
    subsections.
 
    Note that 'fname' can be '-' to send the logging data to stderr.
-   If 'fname' includes the substring '$$', it is replaced with the
+   If 'fname' includes the substring '%d' it is replaced with the
    current process id and you get the log for all subprocesses (and
-   forks) in different files.  If 'fname' does not include '$$', it is
+   forks) in different files.  If 'fname' does not include '%d', it is
    removed from the environment and not passed to subprocesses.
 */
 
diff --git a/rpython/translator/c/test/test_standalone.py b/rpython/translator/c/test/test_standalone.py
--- a/rpython/translator/c/test/test_standalone.py
+++ b/rpython/translator/c/test/test_standalone.py
@@ -544,7 +544,7 @@
         t, cbuilder = self.compile(entry_point)
         path = udir.join('test_debug_print_fork.log')
         out, err = cbuilder.cmdexec("", err=True,
-                                    env={'PYPYLOG': ':%s.$$' % path})
+                                    env={'PYPYLOG': ':%s.%%d' % path})
         assert not err
         import time
         time.sleep(0.5)    # time for the forked children to finish


More information about the pypy-commit mailing list