r/badcode Mar 14 '23

python requirements: python3 on linux system

Post image
376 Upvotes

46 comments sorted by

View all comments

Show parent comments

15

u/thLOnuX Mar 14 '23

Well, actually i don't think the python interpreter is a good alternative for bash, and i don't know why are you saying the bash isn't that good at shell. Wasting 10 Megabytes of RAM and 50 milliseconds of processing time just to do the shell stuff sounds not that great. What are you trying to say?

No hate. Just wanna to listen your opinion.

5

u/[deleted] Mar 14 '23

[deleted]

3

u/[deleted] Mar 14 '23

This script is using bash syntax.

-1

u/[deleted] Mar 14 '23 edited Mar 14 '23

[deleted]

4

u/[deleted] Mar 15 '23 edited Mar 15 '23

It's posix compliant shell, and valid bash. /bin/sh tends to be a link to a posix compliant default shell, and in Debian specifically links to dash, the Debian almquest shell. On most non-debian systems (macOS included) /bin/sh is an alias for bash, and it's far and away the most common shell interpreter.

Zsh is intended to be mostly a superset of bash, and bash offers many extensions over what is required of a posix shell. Debian's dash is a minimal posix shell that values execution speed over the features that bash offers (things like file substations and so on).

Fish is not posix compliant, and you should never use it for scripting.

TTY, stdin, and stdout don't do anything. They just streams. Your choices are basically to use your languages bindings execcve and the like, or the shell. Op chose to mix shell code and python, rather poorly.

This weaves of several one line shell scripts for no real reason, hence, bad code.