You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
BUG - (Windows) Errors due to hardcoded colon as path separator #264
On Windows, the path separator is a semicolon, whereas on unix it is a colon.
In many places in aa, a colon is hardcoded to be used in interactions with paths. This gives both direct and indirect errors when running aa.
Unfortunately, the colon also has other uses in matlab code, thus there are more than 10k places where it appears in the code.
** To fix **
Use the matlab provided pathsep instead of a hardcoded colon
At least, the 100 places with ':' should be looked at. However, that will not cover all problems, as the : will also be part of longer strings (in regular expressions for instance).
For more complete coverage, create a script that can go over all places in m files where the : is used, and does regular expression matching to reduce the number of suspect lines that should be manually looked at.
changed the title [-]BUG - Errors due to hardcoded colon as path separator[/-][+]BUG - (Windows) Errors due to hardcoded colon as path separator[/+]on Nov 5, 2021
% Path for matlabtools
if isfield(aap.directory_conventions,'matlabtoolsdir') && ~isempty(aap.directory_conventions.matlabtoolsdir)
addpath(strrep(aap.directory_conventions.matlabtoolsdir,':',pathsep))
end
It seems to me, that the strrep does not do anything on *nix systems, so why is it not just addpath(aap.directory_conventions.matlabtoolsdir) within the if?
For Windows compatibility, will need to change this code, however I do not yet understand it.
The reason for this implementation is to allow specifying multiple directories separated with ":" (which is the conventional list separator in aa XML).
You are right, in *nix systems, strrep is not needed. And for Windows, we may have to come up with a more clever solution (e.g ignoring ":" before "\").
Activity
[-]BUG - Errors due to hardcoded colon as path separator[/-][+]BUG - (Windows) Errors due to hardcoded colon as path separator[/+]AljenU commentedon Nov 8, 2021
In aa_init, there is the following code
It seems to me, that the strrep does not do anything on *nix systems, so why is it not just
addpath(aap.directory_conventions.matlabtoolsdir)within the if?For Windows compatibility, will need to change this code, however I do not yet understand it.
@tiborauer Ideas?
tiborauer commentedon Nov 8, 2021
The reason for this implementation is to allow specifying multiple directories separated with ":" (which is the conventional list separator in aa XML).
You are right, in *nix systems, strrep is not needed. And for Windows, we may have to come up with a more clever solution (e.g ignoring ":" before "\").
Adapt aa_init to use pathsep and filesep functions
Fix: use pathsep to split paths out of genpath
Fix: use pathsep to split paths out of genpath