ebu

πŸ³οΈβ€πŸŒˆπŸŸ¦πŸ•

gay blue dog
send pets (plz)


tried my hand at more intense shell scripting and WOW i had a terrible time. why is the distinction between $foo and "$foo" important. why can't i just create a scoped block so my shell setup scripts don't leak variables all over my interactive shell. why do we have [ ] and also [[ ]]. what on god's green flat earth is "${#array[@]}". did array.length kill your parents or something. why does printf %f apple/banana cause a division by zero error. i mean i know why but why does it silently do something very wrong instead of erroring out earlier. why do i have to manually specify that using undefined variables is an error. on that note, i get why setopt -e is a thing, but why is there no way to mark a command as "i know this can fail that's why i wrote maybe_result=bar please just let me retrieve the non-zero exit code instead of closing my whole script for me thank you". i get that color's not that important in the grand scheme of things but printf "\033[31m%s\033[0m" "blah blah blah" gets real old real quick. it's hella verbose but at least i can read <span style="color: red;">this</span> without having to scan left and right over and over. much has been said about whitespace sensitivity but dear gods why is the whitespace in my strings significant.

shellcheck (in vscode/vscodium) saved my fuzzy gray ass many times but often only raised more questions. and it sure as hell didn't save me from subshell surprises (though perhaps no such tooling really can in a general sense).

maybe i need to be looking into more / better python tooling. if python has good static typing these days i might just pick that in the future for my scripts.


You must log in to comment.

in reply to @ebu's post:

python has decent static typing support if you can use 3.8+ and it's really decent if you can use 3.10+.

There are still some common python idioms that are pretty hard to type, but it's very possible to stick to a subset of the language that's pretty pleasant.

For simple scripts, I've got no real complaints.

since 3.10 iirc you don't have to import List and Dict from typing and can just use the normal types as your hints, they added a "Self" metatype, and it's all around easier to do most of the basics.

You'll still tear your hair out trying to type dunders and decorators, but for most "normal" code it's not too bad.

If you're getting clever and very meta-programmy, it can still be a big headache. Still no recursive type support, AFAIK. Still a pain for JSON-y types, but pydantic lib is pretty good for that.

This is such a mood. Every time I need to write a shell script (a couple times a year?) I feel like thirty years of programming experience has just been discarded. I am a child again poking at this ineffable machine with its capricious demands and unhelpful error messages and opaque idioms. I have programmed in BASIC and Forth and Pascal and Scheme and Java and C# and Prolog and C and 6502 assembler and so many others and none of them, not even flipping Befunge has felt as arbitrary and alien as shell.

glad to know the struggle is not unique at least. i can understand from a system- and language-design perspective why POSIX-like shell languages are like this -- "everything's just text / everything's a file" and all that jazz. but damn if it doesn't introduce just as much hair-pulling as it does power when everything is a string