← Back to team overview

curtin-dev team mailing list archive

Re: [Merge] ~raharper/curtin:fix/udevadm-info-shlex-quote into curtin:master

 

Thanks.  shlex.quote() is designed to make the string usable directly in shell, like so:

% lxc exec x1 bash
root@x1:~# lsb_release -rd
Description:	Ubuntu 16.04.6 LTS
Release:	16.04
root@x1:~# python3
Python 3.5.2 (default, Apr 16 2020, 17:47:17) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import shlex
>>> def shlex_quote(v):
...     return "'" + v.replace("'", "\'\"\'\"\'") + "'"
... 
>>> value="SanDisk'"
>>> value
"SanDisk'"
>>> shlex.quote(value)
'\'SanDisk\'"\'"\'\''
>>> shlex_quote(value)
'\'SanDisk\'"\'"\'\''
>>> print(shlex.quote(value))
'SanDisk'"'"''
>>> 
root@x1:~# echo 'SanDisk'"'"''
SanDisk'

-- 
https://code.launchpad.net/~raharper/curtin/+git/curtin/+merge/382993
Your team curtin developers is requested to review the proposed merge of ~raharper/curtin:fix/udevadm-info-shlex-quote into curtin:master.


References