aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/rc
AgeCommit message (Collapse)AuthorFilesLines
2021-01-14rc: do not exit on EINTR from readRuss Cox1-1/+10
This happens if lldb attaches to rc.
2020-05-18rc: avoid problematic internal names "var", "thread"Russ Cox1-0/+6
For AIX.
2020-05-05rc: clean up parser levels, disallow free carats on listsRuss Cox4-31/+37
2020-05-04rc: allow unquoted = in command argumentsRuss Cox2-10/+27
dd fans rejoice! Also helps with commands like go test -run=x.
2020-05-04rc: move free carat handling into parserRuss Cox4-74/+103
This fixes at least one shell script (printfont) that expected 'x'`{y}'z' to mean 'x'^`{y}^'z' as it now does. Before it meant: 'x'^`{y} 'z' One surprise is that adjacent lists get a free carat: (x y z)(1 2 3) is (x1 y2 z3) This doesn't affect any rc script in Plan 9 or plan9port.
2020-05-04rc: move newline handling into parserRuss Cox6-24/+67
2020-05-04rc: add recursive descent parserRuss Cox13-9/+730
The old yacc-based parser is available with the -Y flag, which will probably be removed at some point. The new -D flag dumps a parse tree of the input, without executing it. This allows comparing the output of rc -D and rc -DY on different scripts to see that the two parsers behave the same. The rc paper ends by saying: It is remarkable that in the four most recent editions of the UNIX system programmer’s manual the Bourne shell grammar described in the manual page does not admit the command who|wc. This is surely an oversight, but it suggests something darker: nobody really knows what the Bourne shell’s grammar is. Even examination of the source code is little help. The parser is implemented by recursive descent, but the routines corresponding to the syntactic categories all have a flag argument that subtly changes their operation depending on the context. Rc’s parser is implemented using yacc, so I can say precisely what the grammar is. The new recursive descent parser here has no such flags. It is a straightforward translation of the yacc. The new parser will make it easier to handle free carats in more generality as well as potentially allow the use of unquoted = as a word character. Going through this exercise has highlighted a few dark corners here as well. For example, I was surprised to find that x >f | y >f x | y are different commands (the latter redirects y's output). It is similarly surprising that a=b x | y sets a during the execution of y. It is also a bit counter-intuitive x | y | z x | if(c) y | z are not both 3-phase pipelines. These are certainly not things we should change, but they are not entirely obvious from the man page description, undercutting the quoted claim a bit. On the other hand, who | wc is clearly accepted by the grammar in the manual page, and the new parser still handles that test case.
2020-01-10Trivial changes: whitespace and modes.Dan Cross5-10/+10
Remote whitespace at the ends of lines. Remove blank lines from the ends of files. Change modes on source files so that they are not executable. Signed-off-by: Dan Cross <cross@gajendra.net>
2020-01-02cmd/rc: fix declarations of some externally linked variablesNeven Sajko2-3/+2
Change-Id: If8fe1afecb9fe55f85e8e5af37521b83e787d718
2018-01-17rc: use proper type for storing ulimit valuesRay Lai1-6/+7
rc on amd64 stores ulimit values as 32-bit int, but the limits on OpenBSD amd64 can exceed 2^31, so "ulimit -a" shows some values as negative. This is a problem when I want to increase my ulimit but the hard ulimit values are printed as negative.
2017-09-14all: remove .cvsignore filesKare Nuorteva1-3/+0
Rename following .cvsignore files to .gitkeep since they are required by the build (directories must exist before build): - bin/fossil/.gitkeep - bin/fs/.gitkeep - bin/venti/.gitkeep Change-Id: I9c2865058480cffb3a4613f25e2eca1f7e5578c0
2013-03-19rc: avoid undefined CXi Wang1-4/+4
There are two bugs in pdec() on INT_MIN: * wrong output. `n = 1-n' should be `n = -1-n' when n is INT_MIN. * infinite loop. gcc optimizes `if(n>=0)' into `if(true)' because `-INT_MIN' (signed integer overflow) is undefined behavior in C, and gcc assumes the negation of a negative number must be positive. The resulting binary keeps printing '-' forever given INT_MIN. Try the simplified pdec.c below. $ gcc pdec.c $ ./a.out -2147483648 --214748364* $ gcc pdec.c -O2 $ ./a.out -2147483648 <infinite loop> $ gcc pdec.c -O2 -D__PATCH__ $ ./a.out -2147483648 -2147483648 === pdec.c === #include <stdio.h> #include <stdlib.h> #include <limits.h> #define io void void pchr(io *f, int c) { putchar(c); } void pdec(io *f, int n) { if(n<0){ #ifndef __PATCH__ n=-n; if(n>=0){ pchr(f, '-'); pdec(f, n); return; } /* n is two's complement minimum integer */ n = 1-n; #else if(n!=INT_MIN){ pchr(f, '-'); pdec(f, -n); return; } /* n is two's complement minimum integer */ n = -(INT_MIN+1); #endif pchr(f, '-'); pdec(f, n/10); pchr(f, n%10+'1'); return; } if(n>9) pdec(f, n/10); pchr(f, n%10+'0'); } int main(int argc, char **argv) { int n = atoi(argv[1]); pdec(NULL, n); putchar('\n'); } R=rsc CC=plan9port.codebot https://codereview.appspot.com/7241055
2011-08-02rc: silence lion roarRuss Cox1-0/+1
R=rsc http://codereview.appspot.com/4835048
2011-02-16rc: fix $ifs bug introduced with utf-8 codeRuss Cox1-2/+4
R=rsc http://codereview.appspot.com/4187050
2011-01-02rc: handle 4-byte utf-8Russ Cox3-0/+20
R=rsc http://codereview.appspot.com/3833043
2011-01-02rc: handle utf-8 in $ifsRuss Cox1-8/+16
R=rsc http://codereview.appspot.com/3798046
2009-09-13rc: implement and document <>{cmd} notationMichael Teichgräber1-17/+47
http://codereview.appspot.com/105061
2009-08-23rc: make read not ignore interrupts/errors (again)Michael Teichgräber1-2/+7
http://codereview.appspot.com/110042
2009-08-08rc: fix segfault when SIGINT is receivedMichael Teichgräber1-1/+2
Save the value of `runq' at the start of the function, so that the `pc' update at the end does work on that original value, and not on a probably modified value of `runq'. fixes #14 http://code.swtch.com/plan9port/issue/14/ http://codereview.appspot.com/104066
2008-08-14rc: fix local variables in functionsRuss Cox2-4/+4
reported by micah stetson: fn foo { echo $bar } bar=baz foo
2008-07-20rc: add subscript sequences (Erik Quanstrom)Russ Cox1-5/+35
2007-03-28keep path and PATH in syncrsc1-0/+2
2007-03-26do not redefine rewindrsc1-1/+1
2007-03-26more memory errors (valgrind)rsc3-1/+3
2007-03-26fix waitrsc5-251/+97
2007-03-26fix phantom rc crashesrsc1-0/+1
2007-03-26sync with plan 9rsc23-1232/+1967
2007-03-25cope with programs that leave fd in non-blocking mode (Tim Wiess)rsc2-1/+27
2006-06-27experiment - allow = in words late in the command linersc1-0/+3
2006-04-08add exitcodersc1-0/+11
2006-04-01Use gcc -ansi -pedantic in 9c. Fix many non-C89-isms.rsc2-3/+3
2006-03-20update lucidarsc1-1/+1
2006-02-14shut up about signals in scriptsrsc1-1/+1
2005-08-11Add rfork builtin.rsc1-0/+53
2005-08-11make sure errors cause non-zero exit statusrsc1-0/+2
2005-07-26fixes from bengt for sunrsc1-2/+2
2005-07-14ignore window size changersc1-0/+1
2005-07-13stupid sunrsc1-0/+3
2005-05-19set $PLAN9 if necessaryrsc1-0/+3
2005-03-18try harder to put background jobs in background; do not print in response to ↵rsc4-1/+45
SIGPIPE
2005-03-18correct command-printing bugrsc1-1/+3
2005-02-13handle /dev/stdin alwaysrsc2-3/+3
2005-02-11set pid=-1 explicitlyrsc1-0/+1
2005-01-23more searchpath-related changesrsc2-1/+2
2005-01-19use correct yaccrsc1-1/+0
2005-01-13Many small edits.rsc1-0/+1
2005-01-12maintain $path and $PATH simultaneouslyrsc5-4/+74
2005-01-07success on the sunrsc1-0/+16
2004-12-28FreeBSD tweaksrsc1-4/+2
2004-10-17print out signalled exitsrsc1-0/+5