mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
read -S
now correctly handles nested double quotes
Prior to this bugfix, the following set of commands would fail to print two double quotes: IFS=',' read -S a b c <<<'foo,"""title"" data",bar' echo $b This fix is from ksh93v- 2013-10-10-alpha, although it has been revised to use stakputc to put the required double quote into the buffer for consistency with the ksh93u+ codebase. src/cmd/ksh93/bltins/read.c: - When handling nested double quotes, put the required double quote in read's buffer with stakputc. src/cmd/ksh93/tests/builtins.sh: - Add the regression test for `read -S` from ksh93v-. src/cmd/ksh93/sh.1: - Fix a minor formatting error to highlight '-S' in the ksh(1) man page.
This commit is contained in:
parent
5498d9ec25
commit
af0bd6ad70
5 changed files with 21 additions and 3 deletions
|
@ -566,13 +566,21 @@ int sh_readline(register Shell_t *shp,char **names, volatile int fd, int flags,s
|
|||
#endif /*SHOPT_MULTIBYTE */
|
||||
case S_QUOTE:
|
||||
c = shp->ifstable[*cp++];
|
||||
inquote = !inquote;
|
||||
if(inquote && c==S_QUOTE)
|
||||
c = -1;
|
||||
else
|
||||
inquote = !inquote;
|
||||
if(val)
|
||||
{
|
||||
stakputs(val);
|
||||
use_stak = 1;
|
||||
*val = 0;
|
||||
}
|
||||
if(c==-1)
|
||||
{
|
||||
stakputc('"');
|
||||
c = shp->ifstable[*cp++];
|
||||
}
|
||||
continue;
|
||||
case S_ESC:
|
||||
/* process escape character */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue