From 27a62213101b02dcc95e2080925c0a777aa1866e Mon Sep 17 00:00:00 2001 From: onefang Date: Wed, 18 Aug 2021 23:28:20 +1000 Subject: Fix up the early "make sure we are in the correct directory" changes. --- src/sledjchisl/sledjchisl.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/sledjchisl/sledjchisl.c b/src/sledjchisl/sledjchisl.c index 3e216c0..e63cdec 100644 --- a/src/sledjchisl/sledjchisl.c +++ b/src/sledjchisl/sledjchisl.c @@ -7669,7 +7669,7 @@ int scanForConfigs(char **cPaths) void sledjchisl_main(void) { char *cmd = *toys.optargs; - char *tmp, *t0, *t1; + char *tmp, *t0 = NULL, *t1 = NULL; struct stat statbuf; int status, result, i; void *vd; @@ -7795,11 +7795,19 @@ Other possibilities - if (qfile_exist(toybuf)) { chdir(toybuf); + free(pwd); + pwd = xgetcwd(); + I("Now running in directory %s", pwd); + free(t0); + t0 = realpath(pwd, NULL); result = scanForConfigs(cPaths); result = result | scanForConfigs(oPaths); } else + { C("The configured scRoot doesn't exist! Might need to actually install this. %s", scRoot); + goto finished; + } } free(t1); } @@ -7827,11 +7835,14 @@ Other possibilities - if ((tmp = configs->getstr(configs, "webIframers", false)) != NULL) {webIframers = tmp; V("Setting webIframers = %s", webIframers);} } else + { C("No sledjChisl.conf.lua found!"); + goto finished; + } snprintf(toybuf, sizeof(toybuf), "%s/current/bin", scRoot); t1 = realpath(toybuf, NULL); - if (strcmp(t0, t1)) + if ((NULL != t0) && (strcmp(t0, t1))) C("scRoot moved unexpectedly, check your sledjChisl.conf.lua files! %s != %s", t0, t1); free(t1); free(t0); @@ -7912,8 +7923,7 @@ Other possibilities - V("Not running inside the proper tmux server. %s == %s", eTMUX, toybuf); } -// Note this block of code assumes we are running inside current/bin. Which RunIt.sh does for us. -// TODO - get rid of RunIt.sh as well. +// Note this block of code assumes we are running inside current/bin. Which RunIt.sh does for us. Earlier code also tries to ensure this. if (!isTmux) { // Let's see if the proper tmux server is even running. i = shellMe("%s %s/%s -q list-sessions 2>/dev/null | grep -q %s:", Tcmd, scRun, Tsocket, Tconsole); -- cgit v1.1