Releases: tusharsadhwani/zxpy
Releases Β· tusharsadhwani/zxpy
Add support for raw shell-strings
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.
Fix printing logic
Previously, only a few select ~'...'
statements were being printed out, rather than any bash-string without any assignments to its left. This patch version fixes printing logic.
Fix bug with global scope
Fixes the previous broken build, refer #19
Fix __name__ global definition
Fix __name__ and argument parsing
__name__
will now be'__main__'
, just like how it is when running any other file directly- Passing additional arguments to
zxpy
command is now supported
Add argument quoting inside bash fstrings
Anything passed as an f-string into a bash string will be automatically quoted with shlex.quote
.
i.e., ~f'{xyz}'
is the same as ~f'{shlex.quote(xyz)}
Add stderr and return code support
- Alternate method of invoking shell commands:
stdout, stderr, return_code = ~'...'
. Fixes #6 - Add a few tests.
Fix `sys.argv`
- Removes zxpy executable from sys.argv, to mimic default python behaviour (#10)
Bugfixes
- Finally figured out the correct way to handle
expr
transformations. Cleaned up a bunch of AST code. - Shell strings and shell f-strings should be usable inside call statements now, eg.
print(~'echo test')
Housekeeping
- Renamed
zx.start()
tozx.install()
for clarity