summaryrefslogtreecommitdiff
path: root/sys/src/cmd/rc/simple.c
AgeCommit message (Collapse)Author
2022-10-30rc: make `flag f [+-]` clear status on successMichael Forney
Otherwise, the old status will be retained, which may be non-empty if it follows an if command whose branch wasn't taken. This is problematic for scripts using -e.
2022-01-03rc: make it portable (for UNIX)cinap_lenrek
Fixup remaining Plan9 dependencies (chartorune()). Add Makefile for UNIX-like systems (tested with Linux and APE). Make error printing consistent, use Errstr() explicitely. Get rid of NSTATUS buffer limit, just malloc it.
2021-12-31rc: fix everythingcinap_lenrek
Untangle the lexer and interpreter thread state. Fix the file and line number error reporting, getting rid of Xsrcfile instruction, as the whole code block can only come from a single file, stuff the source file in slot[1] of the code block instead. Remove limitations for globber (path element limits) and be more intelligent about handling globbing by inserting Xglob instruction only when needed and not run it over every Xsimple argument list. Remove fragile ndot magic and make it explicit by adding the -q flag to . builtin command. Add -b flag for full compilation. Make exitnext() smart, so we can speculate thru rcmain and avoid the fork(). Get rid of all print(2) format functions and use io instead. Improve the io library, adding rstr() to handle tokenization, which allows us to look ahead in the already read buffer for the terminators, avoiding alot of string copies. Auto indent pcmd(), to make line number reporting more usefull. Implement here documents properly, so they can work everywhere.
2021-06-22rc: correct line numbersOri Bernstein
When loading a file using ".", we could end up with our line numbers thrown off due to the mutation of lexline. Putting lexline into the runq beside the file that we're reading from causes it to get pushed and popped correctly, so that we no longer lose track of our location.
2020-11-01rc: show line numbers on errorOri Bernstein
This change provides a location for errors like 'null list in concatenation'.
2020-05-30rc: avoid forking for final command that has variable assignments (to get ↵cinap_lenrek
$apid right) basically, we want the following commands to print the same pid twice: rc -c 'cat /dev/pid &;echo $apid' vs: rc -c 'a=1 cat /dev/pid &;echo $apid' basically, Xsimple() calls exitnext() to determine if a simple command should be promoted to exec, by peeking ahead into the code and searching for Xexit instruction. Xexit might not follow immediately after the Xsimple instruction because of redirections, which exitnext() would skip. but it would not skip the Xunlocal instructions that where added by the variable assignment.
2018-10-27rc: skip searchpath for "", "." and ".."cinap_lenrek
2018-10-26rc: use searchpath() logic to handle $cdpathcinap_lenrek
2018-10-26rc: ignore $cdpath for # device rooted paths (thanks kivik)cinap_lenrek
2016-06-30rc: write /dev/wdir after printing the prompt, not after executing "cd" commandcinap_lenrek
2016-05-15rc: fix shift regresison, sorrycinap_lenrek
2016-05-15rc: remove pointless Memcpy(),Malloc(),Realloc() and efree() wrapperscinap_lenrek
2016-05-15rc: fix inband globbing bugs, cleanupcinap_lenrek
add glob information to the word structure so we wont accidently deglob quoted strings containing the GLOB. we store Globsize(word) in in word->glob which avoids recalculating that values and the check if a word should be globbed quick. globlist() now substitutes the word inplace avoiding the copying when all words are literals and avoids recursion. minor cleanups: use list2str() in execeval(), move octal() to unix.c, remove the (char*) casts to efree().
2016-02-22rc: terminate rc when exec fails, cleanupcinap_lenrek
The execexec() function should never return, as it irreversably changes the filedescriptor table for the new program. This means rc's internal filedesciptors for reading the script get implicitely closed and we cannot continue the rc interpreter when Execute() fails. So Execute() now sets the error status, and execexec() runs Xexit() in case Execute() returns.
2014-07-23rc: fix slow Xqdol(), avoid recursion in conclist(), estrdup(), avoid copyingcinap_lenrek
Xqdol() used to take quadratic time because of strcat(), the code isnt really needed as list2str() aready does the same thing in linear time without the strcat(). add estrdup() which uses emalloc() so allocation error are catched. move strdups() of name from callers into newvar(). avoid recursion of conclist(), and avoid copying of word strings by providing Newword() function which doesnt copy the word string.
2011-03-30Import sources from 2011-03-30 iso image - libTaru Karttunen
2011-03-30Import sources from 2011-03-30 iso imageTaru Karttunen