aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/rc
Commit message (Collapse)AuthorAgeFilesLines
* src/cmd/rc: import rc syntax `delim{cmd} for splitting commands from 9atomlufia2025-07-276-10/+34
| | | | Co-authored-by: <ori@eigenstate.org>
* all: remove need for `-fcommon`Dan Cross2025-07-254-18/+36
| | | | | | | | | | Use `extern` where appropriate so that we can remove `-fcommon` on macOS and others. On macOS, `-fcommon` generates a number of linker warnings. I've tested building on macOS, Linux, FreeBSD, NetBSD, OpenBSD and illumos. I am not in a position to test on AIX or other more esoteric platforms, however.
* config: add $egrepDan Cross2025-07-231-1/+9
| | | | | | | | | | | Introduce a new variable set in $PLAN9/config: $egrep, which is conditionally set to either `egrep` or `grep -E`, based on platform, and use this when we want to invoke `egrep`. This works around the endless warnings from GNU grep stating that `egrep` is deprecated in favor of `grep -E`, when run on e.g. Linux.
* rc: remove dead code.Ori Bernstein2022-05-111-2/+0
| | | | kencc warns that this code is dead.
* rc: do not exit on EINTR from readRuss Cox2021-01-141-1/+10
| | | | This happens if lldb attaches to rc.
* rc: avoid problematic internal names "var", "thread"Russ Cox2020-05-181-0/+6
| | | | For AIX.
* rc: clean up parser levels, disallow free carats on listsRuss Cox2020-05-054-31/+37
|
* rc: allow unquoted = in command argumentsRuss Cox2020-05-042-10/+27
| | | | | | dd fans rejoice! Also helps with commands like go test -run=x.
* rc: move free carat handling into parserRuss Cox2020-05-044-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.
* rc: move newline handling into parserRuss Cox2020-05-046-24/+67
|
* rc: add recursive descent parserRuss Cox2020-05-0413-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.
* Trivial changes: whitespace and modes.Dan Cross2020-01-105-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>
* cmd/rc: fix declarations of some externally linked variablesNeven Sajko2020-01-022-3/+2
| | | | Change-Id: If8fe1afecb9fe55f85e8e5af37521b83e787d718
* rc: use proper type for storing ulimit valuesRay Lai2018-01-171-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.
* all: remove .cvsignore filesKare Nuorteva2017-09-141-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
* rc: avoid undefined CXi Wang2013-03-191-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
* rc: silence lion roarRuss Cox2011-08-021-0/+1
| | | | | R=rsc http://codereview.appspot.com/4835048
* rc: fix $ifs bug introduced with utf-8 codeRuss Cox2011-02-161-2/+4
| | | | | R=rsc http://codereview.appspot.com/4187050
* rc: handle 4-byte utf-8Russ Cox2011-01-023-0/+20
| | | | | R=rsc http://codereview.appspot.com/3833043
* rc: handle utf-8 in $ifsRuss Cox2011-01-021-8/+16
| | | | | R=rsc http://codereview.appspot.com/3798046
* rc: implement and document <>{cmd} notationMichael Teichgräber2009-09-131-17/+47
| | | | http://codereview.appspot.com/105061
* rc: make read not ignore interrupts/errors (again)Michael Teichgräber2009-08-231-2/+7
| | | | http://codereview.appspot.com/110042
* rc: fix segfault when SIGINT is receivedMichael Teichgräber2009-08-081-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
* rc: fix local variables in functionsRuss Cox2008-08-142-4/+4
| | | | | | | reported by micah stetson: fn foo { echo $bar } bar=baz foo
* rc: add subscript sequences (Erik Quanstrom)Russ Cox2008-07-201-5/+35
|
* keep path and PATH in syncrsc2007-03-281-0/+2
|
* do not redefine rewindrsc2007-03-261-1/+1
|
* more memory errors (valgrind)rsc2007-03-263-1/+3
|
* fix waitrsc2007-03-265-251/+97
|
* fix phantom rc crashesrsc2007-03-261-0/+1
|
* sync with plan 9rsc2007-03-2623-1232/+1967
|
* cope with programs that leave fd in non-blocking mode (Tim Wiess)rsc2007-03-252-1/+27
|
* experiment - allow = in words late in the command linersc2006-06-271-0/+3
|
* add exitcodersc2006-04-081-0/+11
|
* Use gcc -ansi -pedantic in 9c. Fix many non-C89-isms.rsc2006-04-012-3/+3
|
* update lucidarsc2006-03-201-1/+1
|
* shut up about signals in scriptsrsc2006-02-141-1/+1
|
* Add rfork builtin.rsc2005-08-111-0/+53
|
* make sure errors cause non-zero exit statusrsc2005-08-111-0/+2
|
* fixes from bengt for sunrsc2005-07-261-2/+2
|
* ignore window size changersc2005-07-141-0/+1
|
* stupid sunrsc2005-07-131-0/+3
|
* set $PLAN9 if necessaryrsc2005-05-191-0/+3
|
* try harder to put background jobs in background; do not print in response to ↵rsc2005-03-184-1/+45
| | | | SIGPIPE
* correct command-printing bugrsc2005-03-181-1/+3
|
* handle /dev/stdin alwaysrsc2005-02-132-3/+3
|
* set pid=-1 explicitlyrsc2005-02-111-0/+1
|
* more searchpath-related changesrsc2005-01-232-1/+2
|
* use correct yaccrsc2005-01-191-1/+0
|
* Many small edits.rsc2005-01-131-0/+1
|