While working on converting configuration variable expansion to use buffers, I noticed $my_ variables were directly expanded, while configuration variables have escaping done (via escape_string() in init.c).

This leads to strange behavior:

set spam_separator = 'foo"bar'
set my_ss = $spam_separator
set spam_separator = $my_ss

$my_ss and $spam_separator both now have the value 'foo\"bar', i.e. they literally have a backslash in their values.

This occurs in the second step, when $spam_separator is expanded, *escaped*, and then assigned to $my_ss. In the third step, $my_ss has no escaping done; the assignment is direct but the damage already occurred in the second step.

Now, I suspect this was done to prevent some kinds of errors with hooks using double quotes, where early expansion would occur and the resulting command is later re-evaluated. Embedded quotes in a variable could cause issues then. (However, I believe the correct thing to do is use single quotes in those cases.)

On the other hand, saving and restoring using $my_ variables is pretty common too, and that doesn't work properly now either.

I'd like to remove the escaping in this case, while performing the BUFFER conversion. Making this change will likely break some configs. Is it worth correcting this?

--
Kevin J. McCarthy
GPG Fingerprint: 8975 A9B3 3AA3 7910 385C  5308 ADEF 7684 8031 6BDA

Attachment: signature.asc
Description: PGP signature

Reply via email to