aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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;