aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2022-04-28 00:07:06 -0700
committerKaz Kylheku <kaz@kylheku.com>2022-04-28 00:07:06 -0700
commitfa7b9cdb6b136254c2b56ceaaf0452d92e159e48 (patch)
tree6bfd768eaee3c1c3f4080c1de5350f7c768b421c
parent7a46e6df55c9148c5a361ce94b09a5c0c0e22b4c (diff)
downloadpw-fa7b9cdb6b136254c2b56ceaaf0452d92e159e48.tar.gz
pw-fa7b9cdb6b136254c2b56ceaaf0452d92e159e48.tar.bz2
pw-fa7b9cdb6b136254c2b56ceaaf0452d92e159e48.zip
Diagnose missing argument in :w, :a and :!.
-rw-r--r--pw.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/pw.c b/pw.c
index cb1c4cd..fdd5846 100644
--- a/pw.c
+++ b/pw.c
@@ -250,7 +250,10 @@ static void execute(char *cmd)
switch (cmd[1]) {
case 'w': case 'a':
- {
+ if (arg[0] == 0) {
+ sprintf(cmd, "file name required!");
+ break;
+ } else {
FILE *f = fopen(arg, cmd[1] == 'w' ? "w" : "a");
int ok = 1;
@@ -272,7 +275,10 @@ static void execute(char *cmd)
}
break;
case '!':
- {
+ if (arg[0] == 0) {
+ sprintf(cmd, "command required!");
+ break;
+ } else {
FILE *p = popen(arg, "w");
int ok = 1;