> var = !cmd syntax
Is this a standard anywhere outside IPython? I would love to use this sort of thing (python with seamless integration with a system shell) in place of bash scripts. Yes, you can use subprocess but it's a lot less readable.
Is this a standard anywhere outside IPython? I would love to use this sort of thing (python with seamless integration with a system shell) in place of bash scripts. Yes, you can use subprocess but it's a lot less readable.
Edit: Things like:
$output=`ls`;
$output=qx#ls -l#;
system('/bin/echo','avoid','subshell','invocation');
open("APIPELINE","ls -l |");
while (<APIPELINE>) {
chomp;
print "Got line: [$_]\n";
}
close(APIPELINE);
And access to child exit status in a way that's familiar ($?), etc.These days, Perl has 3 argument open, and can use a variable for a filehandle. So:
open(my $pipeline, "-|", "ls -l");
This is a good thing, because you can treat a filehandle as a standard variable, and can separate the special stuff from the command itself. This way if you're taking in user input, they don't get to mess with that. You can also do: open(my $pipeline, "-|", "ls", "-l", $directory);
Which lets you get away from the mess of correct quoting and just pass every parameter exactly as intended.[1] https://www.gnu.org/software/ed/manual/ed_manual.html#Comman...
[2] https://docs.julialang.org/en/v1/stdlib/REPL/#man-shell-mode
[4] https://docs.raku.org/language/quoting#index-entry-quote_qqx...