Shell scripts made simple 🐚
Full Changelog: https://github.com/tusharsadhwani/zxpy/compare/1.6.2...1.6.3
Full Changelog: https://github.com/tusharsadhwani/zxpy/compare/1.6.1...1.6.2
zxpy
by itself wouldn't work before this.Added interactive mode option: zxpy -i myfile.py
.
Full Changelog: https://github.com/tusharsadhwani/zxpy/compare/1.5.2...1.6.0
Full Changelog: https://github.com/tusharsadhwani/zxpy/compare/1.5.1...1.5.2
read1()
instead of select polling, to simplify some logicecho -n
, as that is linux-specificAdds Python3.10 support
select
module to do non-blocking reads from the shell process, instead of reading 1 byte at a time. Leads to significantly faster output for large streams, without any blocking.process.communicate()
to read stdout and stderr without causing deadlock due to buffer overflow.~'...'
raises an error if the process exits with a non-zero return code[a, b, c] = ~'...'
Now you can pass whole commands as variables inside f-strings, without quoting.
Take this piece of code:
>>> cmd = 'uname -a'
>>> ~f'{cmd}'
/bin/sh: 1: uname -a: not found
This is because uname -a
was quoted into 'uname -a'
to avoid shell injection.
To avoid this, support for :raw
format_spec as added:
>>> cmd = 'uname -a'
>>> ~f'{cmd:raw}'
Linux pop-os 5.11.0 [...] x86_64 GNU/Linux
Note that this shouldn't be used with external data, or this will expose you to shell injection.