...
  nlen = nend - ntail;
  memcpy (nbeg, ntail, nlen);
  nbeg[nlen] = '\0';

  return name;
...

[nbeg, nbeg+nlen) and [ntail, ntail+nlen) can overlap, so this code should
use memmove. I'm pretty sure this explains why sometimes using
PROMPT_DIRTRIM will give me a prompt with the last few components smeared
over the rest of the string:

/home/mattdr$ echo $PROMPT_DIRTRIM
6
/home/mattdr$ echo $PS1
\w$
/home/mattdr$ cd alpha/beta/gamma/delta/epsilon/zeta/eta/theta/iota/
...eta/iotapsilon/zeta/eta/theta/iota$ pwd
/home/mattdr/alpha/beta/gamma/delta/epsilon/zeta/eta/theta/iota

Note the prompt includes two instances of "iota" but the path only includes
one.

Reply via email to