diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2021-02-13 09:48:58 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2021-02-13 09:48:58 +0000 |
| commit | 5b0ebee290393394d18337f9d707f6b532d3f2a5 (patch) | |
| tree | 04801f4e3159d4ab31b0ab608aad447f68d379b1 | |
| parent | main: -D,--working-directory: check path exists and is a directory (diff) | |
client: -D,--working-directory: check path exists and is a directory
| -rw-r--r-- | client.c | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -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) { |
