ash: improve expandstr()
authorRon Yorston <rmy@pobox.com>
Thu, 23 Jan 2020 11:26:08 +0000 (11:26 +0000)
committerDenys Vlasenko <vda.linux@googlemail.com>
Wed, 29 Jan 2020 12:59:45 +0000 (13:59 +0100)
commitb0c711e64f868fcab0711d8d0f86aaaa4ed93158
tree42a92619ef723cce5153eb0160df8f36cf9dc5c4
parenteb7f9acda147543079f261753a11d2afa340fc5e
ash: improve expandstr()

The dash maintainer recently posted a fix for issues with expanding
PS1.  These had already been fixed differently in BusyBox ash.  Borrow
a couple of improvements:

- Use a single call to setjmp() to trap errors in both readtoken1()
  and expandarg().

- In case of error set the prompt to the literal value of PS1 rather
  than the half-digested nonsense in stackblock() which might include
  ugly control characters.

function                                             old     new   delta
expandstr                                            353     300     -53

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
shell/ash.c