# HG changeset patch # User Aidan Kehoe # Date 1428016518 -3600 # Node ID d93195c2c906d4ee6d31b1820085f43b2cd0de58 # Parent bbe4146603dbdfc8c6e4b5299d7deb6e9ed1a562 Escape quotation marks when printing values interactively, #'getenv src/ChangeLog addition: 2015-04-01 Aidan Kehoe * process.c (Fgetenv): When interactively showing a variable's value, use %S in the format string so quotation marks are escaped correctly. diff -r bbe4146603db -r d93195c2c906 src/ChangeLog --- a/src/ChangeLog Wed Apr 01 14:28:20 2015 +0100 +++ b/src/ChangeLog Fri Apr 03 00:15:18 2015 +0100 @@ -1,3 +1,9 @@ +2015-04-01 Aidan Kehoe + + * process.c (Fgetenv): + When interactively showing a variable's value, use %S in the + format string so quotation marks are escaped correctly. + 2015-03-31 Aidan Kehoe * event-stream.c (Faccept_process_output): diff -r bbe4146603db -r d93195c2c906 src/process.c --- a/src/process.c Wed Apr 01 14:28:20 2015 +0100 +++ b/src/process.c Fri Apr 03 00:15:18 2015 +0100 @@ -2431,11 +2431,11 @@ { Ibyte *value = NULL; Bytecount valuelen; - Lisp_Object v = Qnil; - struct gcpro gcpro1; + Lisp_Object v = Qnil, formatted = Qnil; + struct gcpro gcpro1, gcpro2; CHECK_STRING (var); - GCPRO1 (v); + GCPRO2 (v, formatted); if (getenv_internal (XSTRING_DATA (var), XSTRING_LENGTH (var), &value, &valuelen)) v = make_string (value, valuelen); @@ -2444,9 +2444,11 @@ if (NILP (v)) message ("%s not defined in environment", XSTRING_DATA (var)); else - /* #### Should use Fprin1_to_string or Fprin1 to handle string - containing quotes correctly. */ - message ("\"%s\"", value); + { + /* Backslash any quotation marks. */ + formatted = Fprin1_to_string (v, Qnil); + message_internal (NULL, formatted, 0, -1); + } } RETURN_UNGCPRO (v); }