Advanced-Equipment icon indicating copy to clipboard operation
Advanced-Equipment copied to clipboard

Processing commands with whitespaces in paths

Open y0014984 opened this issue 1 year ago • 0 comments

At the moment all commands and options are splitted via:

private _commandSegments = _input splitString " ";

So it is not possibile to process paths that contain whitespaces/blanks. If we want to allow filenames and dir-names containing whitespaces, then we should insert an additional processing step that parses for " or "'" and then rejoins some command segments like:

(Pseudo code)

private _newCommandSegments = [];
private _stringBuffer = "";
private _quotationMarksCounter = 0;

{
   
   if ((((_x select [0, 1]) isEqualTo """") || ((_x select [0, 1]) isEqualTo "'")) && (_quotationMarksCounter == 0)) then
   {
      _stringBuffer = _stringBuffer + (_x select [1, (count _x) - 1];
      _quotationMarksCounter = 1;
      continue;
   };

   if (_quotationMarksCounter == 1) then
   {
      _stringBuffer = _stringBuffer + _x;
      _quotationMarksCounter = 1;
      continue;
   };

   if (!(((_x select [(count _x) + 1, 1]) isEqualTo """") || ((_x select [(count _x) + 1, 1]) isEqualTo "'")) && (_quotationMarksCounter == 1)) then
   {
      _stringBuffer = _stringBuffer + (_x select [0, (count _x) - 1];
      _quotationMarksCounter = 0;
      _commandSegment pushBack _stringBuffer;
      _stringBuffer = "";
      _continue;
   };

   if (_quotationMarksCounter == 0) then
   {
      _commandSegment pushBack _x;
   };

} forEach _commandSegment;

But we could also decide to not allow whitespaces/blanks in the entire armaOS workflows. In this case we should check all posibilities to create files and dirs (config, modules and commands) and replace whitespaces/blanks by an replacement symbol like _ underscore. Also this needs to be documented.

y0014984 avatar Dec 13 '22 07:12 y0014984