News for hackers. Stuff that matters.
Re:Advanced Bash-Scripting Guide (2014) by aaaaaaaaaaab on Friday August 19, 2022 @02:55PM (#32524775)
Yawn…

Python sucks for building processing pipelines.

How many lines of Python code would you need to implement this?

  paste -d \\n <(foo …) <(bar …) | while read -r f && read -r b; do
    baz “$f” “$b”
  done
Mind you, `foo` and `bar` run in parallel.
Re:Advanced Bash-Scripting Guide (2014) by idispatch on Friday August 19, 2022 @04:34PM (#32525655)
Mind you, before this goes to prod please add error handling and logging. What happens when bar fails? What about baz? Now, please rewrite this so your team mates can maintain and extend. Yawn, I’ll wait for the PR.
Re:Advanced Bash-Scripting Guide (2014) by aaaaaaaaaaab on Friday August 19, 2022 @05:04PM (#32525879)
Gotcha, thanks for the feedback! We should also totally A/B test this! I'll make sure that this ties in with the quarterly OKRs, too! I hope I'll get promoted to E6 for that sweet 10% raise next cycle :fingers_crossed:
Re:Advanced Bash-Scripting Guide (2014) by d0mine on Saturday August 20, 2022 @02:52AM (#32529833)
Nothing stops you from calling bash from Python to combine bash pipelines (onelines) but if you must use Python for some reason, to run `baz` for each line in `foo` & `bar` output:

  from subprocess import Popen, PIPE, run
  
  with Popen('foo', stdout=PIPE) as foo, Popen('bar', stdout=PIPE) as bar:
      for f, b in zip(foo.stdout, bar.stdout):
          run(['baz', f, b])
  
(there is a slight difference in behaviour)
Re:Advanced Bash-Scripting Guide (2014) by slt2021 on Friday August 19, 2022 @03:30PM (#32525114)
replace bash one-liner with python? No, thanks

replace 200+ bash script with multiple subroutines in python? yes

Re:Advanced Bash-Scripting Guide (2014) by dmtroyer on Friday August 19, 2022 @04:42PM (#32525697)
as someone who is maintaining mountains of legacy bash, for all that is holy, yes. or Go. or Rust. anything.