diff options
Diffstat (limited to 'run.c')
-rw-r--r-- | run.c | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -1983,6 +1983,13 @@ void backsub(char **pb_ptr, const char **sptr_ptr) /* handle \\& variations */ { /* sptr[0] == '\\' */ char *pb = *pb_ptr; const char *sptr = *sptr_ptr; + static bool first = true; + static bool do_posix = false; + + if (first) { + first = false; + do_posix = (getenv("POSIXLY_CORRECT") != NULL); + } if (sptr[1] == '\\') { if (sptr[2] == '\\' && sptr[3] == '&') { /* \\\& -> \& */ @@ -1992,6 +1999,9 @@ void backsub(char **pb_ptr, const char **sptr_ptr) /* handle \\& variations */ } else if (sptr[2] == '&') { /* \\& -> \ + matched */ *pb++ = '\\'; sptr += 2; + } else if (do_posix) { /* \\x -> \x */ + sptr++; + *pb++ = *sptr++; } else { /* \\x -> \\x */ *pb++ = *sptr++; *pb++ = *sptr++; |