this post was submitted on 05 Feb 2025
76 points (98.7% liked)

Piracy: ꜱᴀɪʟ ᴛʜᴇ ʜɪɢʜ ꜱᴇᴀꜱ

56352 readers
552 users here now

⚓ Dedicated to the discussion of digital piracy, including ethical problems and legal advancements.

Rules • Full Version

1. Posts must be related to the discussion of digital piracy

2. Don't request invites, trade, sell, or self-promote

3. Don't request or link to specific pirated titles, including DMs

4. Don't submit low-quality posts, be entitled, or harass others



Loot, Pillage, & Plunder

📜 c/Piracy Wiki (Community Edition):

🏴‍☠️ Other communities

Torrenting:

Gaming:


💰 Please help cover server costs.

Ko-Fi Liberapay
Ko-fi Liberapay

founded 2 years ago
MODERATORS
 

It supports thepiratebay, nyaa, 1337x, libgen, limetorrents and rarbg

you are viewing a single comment's thread
view the rest of the comments
[–] Rogue@feddit.uk 1 points 5 hours ago

So, you don’t know Python at all AND you don’t know Bash, but you feel compelled to talk about how one is so much better than the other?

I have plenty of experience with Bash, hence why I was eager to question the implication that bash was less complicated than other solutions.

You're correct that I don't know python, but I do have plenty of familiarity with PHP, JS, C#, and Rust. From my experience with those languages I guessed that python probably has similar libraries for making API calls.

Thanks for providing the actual examples. Looking at them I'm curious if you still think I'm wrong?

In my opinion the bash is much more difficult to understand than the python and therefore it's more likely for bugs to creep in. For example I think curl_exit_code=$? should be called immediately after the curl command as the way it's presently written isn't it capturing the exit code of the tail command?

You've explicitly called --connect-timeout and --max-time. imo it only comes from experience that you need to add these options. I had a script that had been funcitoning without issue for months then suddenly started to hang and it was a while before I figured out that the defaults for curl had no timeout so it didn't gracefully fail like I would expect.

These are the kind of traps that I fall into all the time with bash and it's painful to debug.

response=$(
  curl \
    --silent \
    --write-out "\n%{http_code}" \
    --connect-timeout "$CONNECT_TIMEOUT" \
    --max-time "$MAX_TIME" \
    "$API_URL"
)

http_body=$(echo "$response" | sed '$d')        
http_code=$(echo "$response" | tail -n1)

curl_exit_code=$?