zxpy

Shell scripts made simple 🐚

MIT License

Downloads
976
Stars
650
Committers
3
zxpy - 1.6.3 Latest Release

Published by tusharsadhwani over 1 year ago

What's Changed

Full Changelog: https://github.com/tusharsadhwani/zxpy/compare/1.6.2...1.6.3

zxpy - 1.6.2

Published by tusharsadhwani about 2 years ago

What's Changed

Full Changelog: https://github.com/tusharsadhwani/zxpy/compare/1.6.1...1.6.2

zxpy - 1.6.1

Published by tusharsadhwani over 2 years ago

  • Fix bug in interactive mode invocation: zxpy by itself wouldn't work before this.
zxpy - Interactive mode

Published by tusharsadhwani over 2 years ago

Added interactive mode option: zxpy -i myfile.py.

Full Changelog: https://github.com/tusharsadhwani/zxpy/compare/1.5.2...1.6.0

zxpy - Bugfixes

Published by tusharsadhwani about 3 years ago

What's Changed

New Contributors

Full Changelog: https://github.com/tusharsadhwani/zxpy/compare/1.5.1...1.5.2

zxpy - Fix MacOS tests

Published by tusharsadhwani about 3 years ago

  • use read1() instead of select polling, to simplify some logic
  • remove the use of echo -n, as that is linux-specific
zxpy - Python3.10 support

Published by tusharsadhwani about 3 years ago

Adds Python3.10 support

zxpy - Faster output and no deadlocks

Published by tusharsadhwani about 3 years ago

  • Use the 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.
  • Use process.communicate() to read stdout and stderr without causing deadlock due to buffer overflow.
zxpy - Misc. bugfixes

Published by tusharsadhwani about 3 years ago

  • Ensure the package actually works in Python 3.6+
  • Make sure that ~'...' raises an error if the process exits with a non-zero return code
  • Fix an edge case in supported syntax: [a, b, c] = ~'...'
zxpy - Add support for raw shell-strings

Published by tusharsadhwani about 3 years ago

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.

zxpy - Fix printing logic

Published by tusharsadhwani about 3 years ago

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.

zxpy - Fix bug with global scope

Published by tusharsadhwani over 3 years ago

Fixes the previous broken build, refer #19

zxpy - Fix __name__ global definition

Published by tusharsadhwani over 3 years ago

Refer #18

zxpy - Fix __name__ and argument parsing

Published by tusharsadhwani over 3 years ago

  • __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
zxpy - Add argument quoting inside bash fstrings

Published by tusharsadhwani over 3 years ago

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)}

zxpy - Add stderr and return code support

Published by tusharsadhwani over 3 years ago

  • Alternate method of invoking shell commands: stdout, stderr, return_code = ~'...'. Fixes #6
  • Add a few tests.
zxpy - Fix `sys.argv`

Published by tusharsadhwani over 3 years ago

  • Removes zxpy executable from sys.argv, to mimic default python behaviour (#10)
zxpy - Bugfixes

Published by tusharsadhwani over 3 years ago

  • 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')
zxpy - Housekeeping

Published by tusharsadhwani over 3 years ago

  • Renamed zx.start() to zx.install() for clarity
zxpy - Bugfix

Published by tusharsadhwani over 3 years ago

  • Fix using string attributes over bash f-strings, i.e. (~f'...').splitlines()