4 ms·
Is there a way to switch explicitly between Python and Bash mode? The "ls -l" example makes me pretty worried that this could mess up basic bash scripts that al
by AstroChimpHam 12y ago
Is there a way to switch explicitly between Python and Bash mode? The "ls -l" example makes me pretty worried that this could mess up basic bash scripts that already work just by defining a variable like "ls" and forgetting about it, or forgetting where it's defined. It's a great idea, but there's a lot of room for stuff breaking that worries me.
- sciurus 12y agoYou can use an uncaptured subprocess to run a command explicitly in bash mode. I'm unsure how you think xonsh would break a bash script, though. When you run a script in xonsh it's still going to be interpreted by whatever is declared in the script's shebang. Just like you can run a perl script from bash, you can run a bash script from xonsh. E.G. $ ls='foo' $ cat test.sh #!/bin/bash ls ~ $ print(ls) foo $ ./test.sh bin C:\nppdf32Log\debuglog.txt foo initrd.img.old lost+found opt run sys var boot dev home lib media proc sbin tmp vmlinuz cdrom etc initrd.img lib64 mnt root srv usr vmlinuz.old
- ridiculous_fish 12y agoThe stuff that gets broken are bash scripts that are designed to be sourced directly: virtualenv, rbenv, various prompts, etc.
- bkeroack 12y agoPresumably the shebang at the start of your script would cause it to be executed by bash directly.
- ptx 12y agoI don't think you would replace /bin/bash with this, but rather switch to it as your interactive shell, using "chsh". On FreeBSD, for example, the default shell is /bin/tcsh but scripts are usually written for /bin/sh (with a shebang line). Even if this thing can execute unmodified bash scripts (can it?), it seems to me that would be missing the point, which is to avoid the horror of writing complex bash scripts. When I start writing something in bash, because of those few things it makes so easy (e.g. running subprocesses), I usually regret it as the script grows. If xonsh can make those things just as easy, every script can be written in the right language – which is of course Python :) – from the start.