Closed reckoner closed 4 years ago
Hi. That's because the Python subprocess module passes the command to /bin/sh
by default. So the syntax you're using causes an error. Maybe you could just use Python:
>>> for i in range(2015, 2020):
... print(i)
...
2015
2016
2017
2018
2019
Or use the UNIX seq
command:
>>> seq 2015 2019 | for i in _:
... print(i + ' hello')
2015 hello
2016 hello
2017 hello
2018 hello
2019 hello
I plan to do 2 things that will help you out. One is to make it possible to have a different shell used, and the second it to just have one shell running, not fire a new shell for each command (that will allow persistent variables in the underlying shell). But maybe the above is enough for you to do what you're after?
I just pushed a change that lets you specify the underlying shell. So you may want to invoke daudin
using
$ daudin --shell '/bin/zsh -c'
or you can use DAUDIN_SHELL
so you don't have to think about it any more:
$ export DAUDIN_SHELL='/bin/zsh -c'
(which assumes zsh
is in /bin
and assumes you're using bash
or zsh
).
Note that your foreach
command would need to be on one line because daudin
doesn't know how to send multiple command lines to the same underlying shell. So:
$ daudin --shell '/bin/zsh -c'
>>> foreach i ({2015..2019}); do echo $i; done
2015
2016
2017
2018
2019
or using bash
:
$ daudin --shell '/bin/bash -c'
>>> for i in {2015..2019}; do echo $i; done
2015
2016
2017
2018
2019
whereas with /bin/sh
you'd get:
$ daudin --shell '/bin/sh -c'
>>> for i in {2015..2019}; do echo $i; done
{2015..2019}
Thanks! It makes more sense now. Your comment about not being able to process multiple lines is key.
The following ZSH syntax is failing and I don't understand what the debug message is saying.