mhttpd status page shows "Resource paths" containing just a "."
The mhttpd help page shows various entries for “Resource paths”. Some of them contain $MIDAS_DIR. One entry just shows “.” which does not tell you anything. Would be good to evaluate MIDAS_DIR to the full directory name, and replace “.” with the current working director (which I believe is what it should be). So in the end, all “Resource paths” entries should start with a full path name starting with “/”.
Comments (7)
-
-
reporter Even if “.” is relative to “mhttpd current directory”, I would put there the full directory name and not just “.” That might confuse people.
-
Hmm… for this one, I do want “.” to be there so mhttpd loads files from my development directory (where I started mhttpd). As for confusion about “.” meaning the mhttpd current directory, I think I agree, it is not obvious.
But I do not know how to fix it without completely disallowing relative paths.
Which may not be a bad idea - if only absolute paths are permitted, things work the same regardless in what subdirectory the user runs midas programs. This is a good thing and it fixes some confusion that happened in the past.
For implementation, I would have “cm_canonical_path(const char* filename)” - it would resolve the env.variables $HOME, $MIDASSYS, etc via cm_expand_var() and it would prepend cm_get_path() to all relative paths (that do not start with “/”).
I think this goes on the TODO list for the next release of midas.
K.O.
-
reporter I meant only for display in mhttpd, like
if (path == „.“) path = cm_get_path(); print(path);
-
That should be path = getcwd(), not cm_get_path(). To me this is the gist of confusion created by relative paths. paths relative to what? K.O.
-
reporter Sure, put getcwd() there. Better than „.“
-
reporter - changed status to resolved
I put in now code to replace "." and "$MIDASSYS" with actual directories. Fixed.
- Log in to comment
Confirmed. $MIDAS_DIR is there by mistake, it should be cm_get_path(). ($MIDAS_DIR is only used to construct a synthetic exptab file).
“.” is relative to “mhttpd current directory”, displayed on the “help” page.
I now tend to think that we should not allow non-absolute paths in exptab (and in $MIDASDIR) and prepend all non-absolute paths with cm_get_path() before we use them.
(That said, a few times I did find it handy to use relative (and “.”) paths and starting different programs in different directories).
Things like $MIDASDIR, $MIDASSYS, $HOME, & co are resolved via cm_expand_env(), but this is not used consistently.
K.O.