aboutsummaryrefslogtreecommitdiff
path: root/sway/config.c
diff options
context:
space:
mode:
authorConnor E <38229097+c-edw@users.noreply.github.com>2019-02-24 04:39:08 +0000
committerBrian Ashworth <bosrsf04@gmail.com>2019-02-24 00:01:35 -0500
commitd4b1e71b919a52fbad0ba8191259eb4f14dfd1ab (patch)
tree5933eaa3a951f8b9cae3b63452f9c572b37be7b8 /sway/config.c
parent713883f04cf1f2a2bafb389562a79d98b87909e9 (diff)
Make load_include_configs void. Fix some cases where WD would not be restored.
Diffstat (limited to 'sway/config.c')
-rw-r--r--sway/config.c37
1 files changed, 14 insertions, 23 deletions
diff --git a/sway/config.c b/sway/config.c
index 206ca95c..4cd21bbc 100644
--- a/sway/config.c
+++ b/sway/config.c
@@ -549,43 +549,34 @@ static bool load_include_config(const char *path, const char *parent_dir,
return true;
}
-bool load_include_configs(const char *path, struct sway_config *config,
+void load_include_configs(const char *path, struct sway_config *config,
struct swaynag_instance *swaynag) {
char *wd = getcwd(NULL, 0);
char *parent_path = strdup(config->current_config_path);
const char *parent_dir = dirname(parent_path);
if (chdir(parent_dir) < 0) {
- free(parent_path);
- free(wd);
- return false;
+ sway_log(SWAY_ERROR, "failed to change working directory");
+ goto cleanup;
}
wordexp_t p;
-
- if (wordexp(path, &p, 0) != 0) {
- free(parent_path);
- free(wd);
- return false;
+ if (wordexp(path, &p, 0) == 0) {
+ char **w = p.we_wordv;
+ size_t i;
+ for (i = 0; i < p.we_wordc; ++i) {
+ load_include_config(w[i], parent_dir, config, swaynag);
+ }
+ wordfree(&p);
}
- char **w = p.we_wordv;
- size_t i;
- for (i = 0; i < p.we_wordc; ++i) {
- load_include_config(w[i], parent_dir, config, swaynag);
- }
- free(parent_path);
- wordfree(&p);
-
- // restore wd
+ // Attempt to restore working directory before returning.
if (chdir(wd) < 0) {
- free(wd);
- sway_log(SWAY_ERROR, "failed to restore working directory");
- return false;
+ sway_log(SWAY_ERROR, "failed to change working directory");
}
-
+cleanup:
+ free(parent_path);
free(wd);
- return true;
}
void run_deferred_commands(void) {