mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-27 23:08:31 +00:00
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:
parent
d5b8b644c2
commit
d484e1dbd4
2 changed files with 111 additions and 3 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue