1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00
cde/src/cmd/ksh93/include
Martijn Dekker 06e56251b9 Fix wrong syntax error upon process substitution after redirection
Grammatically, redirections may occur anywhere within a command
line and are removed after processing them, whereas a process
substitution (<(commandlist) or >(commandlist)) is replaced by a
file name which should be treated as just another simple word.
So the following should not be a syntax error:

$ cat </dev/null <(true)
-ksh: syntax error: `)' unexpected
$ cat </dev/null >(true)
-ksh: syntax error: `)' unexpected
$ cat >/dev/null <(true)
-ksh: syntax error: `)' unexpected
$ cat >/dev/null >(true)
-ksh: syntax error: `)' unexpected

This bug is in every ksh93 version.

The problem is in the parser (parse.c). The process substitution is
misparsed as a redirection due to inout() recursively parsing
multiple redirections without recognising process substitutions.
inout() is mistaking '<(' for '<' and '>(' for '>', which explains
the incorrect syntax error.

This also causes the following to fail to detect a syntax error:
$ cat >&1 <(README.md
[the contents of README.md are shown]

...and other syntax errors detected in the wrong spot, for example:
$ { true; } <(echo wrong)
-ksh: syntax error: `wrong' unexpected
which should be:
-ksh: syntax error: `<(' unexpected

src/cmd/ksh93/sh/parse.c:
- Add global inout_found_procsub flag.
- inout(): On encountering a process substitution, set this flag
  and return, otherwise clear the flag.
- simple(): After calling inout(), check this flag and, if set,
  jump back to where process substitutions are parsed.

Resolves: https://github.com/ksh93/ksh/issues/418
2022-07-05 13:20:28 +02:00
..
argnod.h Add error message for ambiguous long-form option abbreviation 2022-06-10 01:11:46 +01:00
builtins.h Update copyright years in files changed since 1st Jan 2022 2022-01-30 20:49:04 +00:00
defs.h [v1.0] remove alarm builtin 2022-06-21 05:45:53 +01:00
edit.h Update copyright years in files changed since 1st Jan 2022 2022-01-30 20:49:04 +00:00
fault.h Yet another round of accumulated tweaks and cleanups 2022-07-04 00:29:05 +02:00
fcin.h INIT: remove proto, ratz (re: 46593a89, 6137b99a); major cleanup 2021-12-24 07:05:22 +00:00
history.h Update copyright years in files changed since 1st Jan 2022 2022-01-30 20:49:04 +00:00
io.h Remove more unused stuff 2022-06-03 18:47:15 +01:00
jobs.h trap: fix use after free (#446) 2022-02-05 13:53:11 +00:00
lexstates.h INIT: remove proto, ratz (re: 46593a89, 6137b99a); major cleanup 2021-12-24 07:05:22 +00:00
name.h restore C90 compat: do not repeat a typedef (re: 3e0da770) 2022-07-03 18:56:47 +02:00
national.h INIT: remove proto, ratz (re: 46593a89, 6137b99a); major cleanup 2021-12-24 07:05:22 +00:00
nval.h Remove more unused stuff 2022-06-03 18:47:15 +01:00
path.h Another round of minor tweaks and cleanups 2022-06-09 03:02:06 +01:00
regress.h Update copyright years in files changed since 1st Jan 2022 2022-01-30 20:49:04 +00:00
shell.h Yet another round of accumulated tweaks and cleanups 2022-07-04 00:29:05 +02:00
shlex.h lex.c: prevent restoring outdated stack pointer 2022-06-23 03:35:48 +01:00
shnodes.h Update copyright years in files changed since 1st Jan 2022 2022-01-30 20:49:04 +00:00
shtable.h Update copyright years in files changed since 1st Jan 2022 2022-01-30 20:49:04 +00:00
streval.h Update copyright years in files changed since 1st Jan 2022 2022-01-30 20:49:04 +00:00
terminal.h Update copyright years in files changed since 1st Jan 2022 2022-01-30 20:49:04 +00:00
test.h Update copyright years in files changed since 1st Jan 2022 2022-01-30 20:49:04 +00:00
timeout.h Add ksh 93u+m contributors notice to 964 copyright headers 2021-04-26 00:19:31 +01:00
ulimit.h Accumulated fixes for minor issues (#442) 2022-01-30 20:42:59 +00:00
variables.h Update copyright years in files changed since 1st Jan 2022 2022-01-30 20:49:04 +00:00
version.h Fix wrong syntax error upon process substitution after redirection 2022-07-05 13:20:28 +02:00