News for hackers. Stuff that matters.
Re:Writing Safe Shell Scripts (2019) by j1elo on Saturday February 01, 2020 @06:06PM (#22213841)
> Practically every Unix/Linux box in existence has at least some version of Python

If we understand "box" as "environment", in general, and not literally a physical or virtual machine...

Not really. E.g. see: every clean Ubuntu Docker container. They don't have Python, nor should have to include it by default.

And if you are going to do something like this:

  apt-get update && apt-get install -y stuff
  wget https://file.tgz
  tar xf file.tgz
  cd file
  make
  make install
  value="$(cat result | grep something)"
  mvn clean install -Dapp.value="$value"
Yeah, this would need proper securing and Shellcheck, but still I'd rather have it written like this, a concise and to the point script, instead of having to install a whole secondary language interpreter and writing a script among 3 to 10 times longer for the same result.

I recently did the opposite of what everybody seems to be doing: moved an 800-line Python script, which you had to read carefully to understand what it was doing, to a 150-line Bash script that you only have to look at, because the important things to know is to see what other, external programs are being called. Just the apt-get stuff in Python was a mess with the poorly documented Python API for Apt, and some 50 lines to just do the same of an apt-get install... effectively wasted mental cycles.

(EDIT: formatting)

Re:Writing Safe Shell Scripts (2019) by effie on Sunday February 02, 2020 @11:40AM (#22217775)
> Python API for Apt

There seems to be something very wrong with this expression. Why would one need API for apt? It's a command-line tool.