[GRASS-git] [OSGeo/grass] 816c25: python/grass/script: split the command string usin...

Tomas Zigo noreply at github.com
Tue Nov 21 11:09:45 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/OSGeo/grass
  Commit: 816c25f62cd6723aa956939b157ac1f3da1c8f44
      https://github.com/OSGeo/grass/commit/816c25f62cd6723aa956939b157ac1f3da1c8f44
  Author: Tomas Zigo <50632337+tmszi at users.noreply.github.com>
  Date:   2023-11-21 (Tue, 21 Nov 2023)

  Changed paths:
    M display/d.vect/d.vect.html
    M python/grass/script/utils.py

  Log Message:
  -----------
  python/grass/script: split the command string using shell-like syntax on the win32 platform same as on POSIX-compliant platforms (#1908)

e.g. run 'd.vect map=census where="cat > 10 AND cat < 20"' with
where parameter from Command Prompt CMD/emulator terminal:

non-POSIX platform

```
>>> import shlex
>>> shlex.split('where="cat > 10 AND cat < 20"', posix=False)
['where="cat', '>', '10', 'AND', 'cat', '<', '20"']
```

POSIX-compliant platform

```
>>> import shlex
>>> shlex.split('where="cat > 10 AND cat < 20"', posix=True)
['where=cat > 10 AND cat < 20']
```

Under OS MS Windows 'd.vect map=census where="cat > 10 AND cat < 20"'
command runned from Command Prompt CMD require use ^ carret symbol for
escaping special characters < > ( ) & | , ; ".

e.g. 'd.vect map=census where="cat ^> 10 AND cat ^< 20"'

---------

Co-authored-by: Anna Petrasova <kratochanna at gmail.com>




More information about the grass-commit mailing list