aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2021-02-13 09:48:31 +0000
committerDaniel Eklöf <daniel@ekloef.se>2021-02-13 09:48:31 +0000
commitf896f12967086cde054d02a0e5b4af1eb8eeb898 (patch)
treeed0380880ebcec2357e4956bc7454b9997d1baa3
parentchangelog: -D,--working-directory=DIR (diff)
main: -D,--working-directory: check path exists and is a directory
-rw-r--r--main.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/main.c b/main.c
index 2b9d3186..87f7a058 100644
--- a/main.c
+++ b/main.c
@@ -236,9 +236,15 @@ main(int argc, char *const *argv)
conf_app_id = optarg;
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 'f':
tll_free_and_free(conf_fonts, free);