Improve system() / popen() builtin shell (#753)

* cocmd: stop splitting redirect expressions
* cocmd: allow passing unpaired } for passing Perl test
* cocmd: propagate exit status from semicolon
This commit is contained in:
Gavin Hayes 2023-04-17 19:18:16 -04:00 committed by GitHub
parent d5b8b644c2
commit d484e1dbd4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 111 additions and 3 deletions

View file

@ -399,7 +399,7 @@ static int Fake(int main(int, char **)) {
}
static int TryBuiltin(void) {
if (!n) return 0;
if (!n) return exitstatus;
if (!strcmp(args[0], "exit")) Exit();
if (!strcmp(args[0], "cd")) return Cd();
if (!strcmp(args[0], "rm")) return Rm();
@ -570,9 +570,14 @@ static char *Tokenize(void) {
if (q > r) {
return Finish();
} else {
Run();
exitstatus = Run();
t = STATE_WHITESPACE;
}
} else if (*p == '>') {
Append(*p);
if (p[1] == '&') {
Append(*++p);
}
} else if (*p == '&') {
if (q > r) {
return Finish();
@ -680,7 +685,8 @@ int _cocmd(int argc, char **argv, char **envp) {
unsupported['('] = true;
unsupported[')'] = true;
unsupported['{'] = true;
unsupported['}'] = true;
unsupported['}'] = false; // Perl t/op/exec.t depends on unpaired } being
// passed from the shell to Perl
if (!_weaken(glob)) {
unsupported['*'] = true;
unsupported['?'] = true;