main: -D,--working-directory: check path exists and is a directory

This commit is contained in:
Daniel Eklöf 2021-02-13 10:48:31 +01:00
parent 37c4917e8e
commit f896f12967
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

8
main.c
View file

@ -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);