News for hackers. Stuff that matters.
Re:The Bash Hackers Wiki by m463 on Friday February 21, 2020 @09:34PM (#22389008)
I like bash, but I sort of have a rule...

If I am thinking of using advanced features of bash, or I'm over-using grep/sed/awk within the script.... switch to python (formerly perl)

Mostly it's a win with respect to quoting, path manipulation and proper data structures.

Re:The Bash Hackers Wiki by _jal on Friday February 21, 2020 @09:58PM (#22389105)
Python's major glaring problem as a systems language is dealing with processes. It is just verbose, ticky and annoying.

I have my other issues with it as a systems language that are more idiosyncratic, but for replacing bash, process management is just way too much hassle.

Re:The Bash Hackers Wiki by chubot on Friday February 21, 2020 @10:02PM (#22389120)
I agree, I basically wrote the same thing in the FAQ for Oil:

http://www.oilshell.org/blog/2018/01/28.html#shouldnt-script...

Re:The Bash Hackers Wiki by m463 on Friday February 21, 2020 @11:54PM (#22389504)
I agree. I basically fall back to a subroutine with try and subprocess.check_output() as shorthand.

However I like this lots:

   subprocess.call(['cmd','with','precise','args',file1])
Re:The Bash Hackers Wiki by Too on Saturday February 22, 2020 @07:45AM (#22390723)
99.9% of all process management can be done with oneliner subprocess.check_output. Not verbose at all and much safer.

Biggest mistake people do is bringing bash idioms into python, like trying to pipe the output through head/cut/tail/grep/sed instead of just using string operators like endswith/in/startswith/re. If you do that then process managment will be more verbose, but it is in bash also unless you ignore decent error handling like $PIPEFAIL[0] which many many scripts actually do unknowingly. For those other 0.1% of the places where you actually need a pipe then just accept that you have to write 4 lines instead of 2, you will save thousands of lines in other places. For parallel running processes &, jobs, nohup and wait in bash isn't exactly convenient either if you are interested in the results, so there it's a tie vs POpen if i'm being generous.

Re:The Bash Hackers Wiki by vaingloriole on Saturday February 22, 2020 @10:38AM (#22391502)
Do you really think the python popen() workalike with optional shell inclusion is better than running in a shell? More secure perhaps? Easier to read? I forced a developer from my team who would not stop using subprocess calls (including $SHELL) in random new python scripts with hard coded arguments instead of writing a single shell script that could be reused. subprocess is a tarpit and is more misused than any other python function.
Re:The Bash Hackers Wiki by saghm on Friday February 21, 2020 @11:24PM (#22389413)
My bar for switching to my scripting language of choice is much lower; as soon as I need any sort of control flow, I switch to Ruby.