aboutsummaryrefslogtreecommitdiff
path: root/client.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2021-02-13 09:48:58 +0000
committerDaniel Eklöf <daniel@ekloef.se>2021-02-13 09:48:58 +0000
commit5b0ebee290393394d18337f9d707f6b532d3f2a5 (patch)
tree04801f4e3159d4ab31b0ab608aad447f68d379b1 /client.c
parentmain: -D,--working-directory: check path exists and is a directory (diff)
client: -D,--working-directory: check path exists and is a directory
Diffstat (limited to 'client.c')
-rw-r--r--client.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/client.c b/client.c
index 125b4cfa..c012555c 100644
--- a/client.c
+++ b/client.c
@@ -10,6 +10,7 @@
#include <sys/socket.h>
#include <sys/un.h>
+#include <sys/stat.h>
#define LOG_MODULE "foot-client"
#define LOG_ENABLE_DBG 0
@@ -125,9 +126,15 @@ main(int argc, char *const *argv)
login_shell = true;
break;
- case 'D':
+ case 'D': {
+ struct stat st;
+ if (stat(optarg, &st) < 0 || !(st.st_mode & S_IFDIR)) {
+ fprintf(stderr, "error: %s: not a directory\n", optarg);
+ return EXIT_FAILURE;
+ }
custom_cwd = optarg;
break;
+ }
case 'w':
if (sscanf(optarg, "%ux%u", &width, &height) != 2 || width == 0 || height == 0) {