summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSigrid Solveig Haflínudóttir <sigrid@ftrv.se>2022-09-16 18:46:46 +0000
committerSigrid Solveig Haflínudóttir <sigrid@ftrv.se>2022-09-16 18:46:46 +0000
commit05b08f6665b8b0c14c0cb4caa42929db8d26c6c9 (patch)
treeb749e6e85017177ea3396f7f64abe7c6b19bac0a
parent6901f0c40f4c72fe730a4daab3ae30f930a5e968 (diff)
pc: remove -n option and check if stdin is cons instead
-rw-r--r--sys/man/1/pc5
-rw-r--r--sys/src/cmd/pc.y12
2 files changed, 5 insertions, 12 deletions
diff --git a/sys/man/1/pc b/sys/man/1/pc
index 287938541..e85e87370 100644
--- a/sys/man/1/pc
+++ b/sys/man/1/pc
@@ -16,11 +16,6 @@ Multiple statements in one line can be separated by semicolons.
.I Pc
prints the value of all expressions that are not terminated by a semicolon.
.PP
-.I Pc
-can be run non-interactively by using the
-.B -n
-switch. In this case no input prompt is printed.
-.PP
Expressions can use the C-like operators
.TP
.B + - * ** \fR(exponentiation\fR)
diff --git a/sys/src/cmd/pc.y b/sys/src/cmd/pc.y
index 8e0fedf32..a9f81c570 100644
--- a/sys/src/cmd/pc.y
+++ b/sys/src/cmd/pc.y
@@ -1025,8 +1025,9 @@ fncat(int n, Num **a)
}
void
-main(int argc, char **argv)
+main(int, char **)
{
+ char buf[32];
Keyword *kw;
fmtinstall('B', mpfmt);
@@ -1056,13 +1057,10 @@ main(int argc, char **argv)
regfunc("rev", fnrev, 2);
regfunc("cat", fncat, -1);
- prompt = 1;
- ARGBEGIN{
- case 'n': prompt = 0; break;
- }ARGEND;
-
+ prompt = fd2path(0, buf, sizeof buf) >= 0 && strstr(buf, "/dev/cons") != nil;
in = Bfdopen(0, OREAD);
- if(in == nil) sysfatal("Bfdopen: %r");
+ if(in == nil)
+ sysfatal("Bfdopen: %r");
extern void yyparse(void);
yyparse();
extern int yynerrs;