@wallhackio i developed a much better intuition fur how shell purrogramming works from reading its multiple chapters on the topic

@aescling the syntax is very confusing and i do not udnerstand what is happening half the time

@vaporeon_ @wallhackio from what i can remember, things like ' and " having diffurent rules regarding substitution, why double quoting $() even works and what that actually does, for requiring do and done (while and case will make him upset when he learns their syntax), he did not know the sed(1) command language and was confused what it was doing, how “booleans” work in shell purrogramming, what a hashbang even is and what it does exactly…

@vaporeon_ @wallhackio i do think shell purrogramming syntax is ultimately quite simple, but that is after i learned about a lot of little hurdles that used to confuse me too

@vaporeon_ @aescling for((i=0; i<${#files[@]}; i++)); do to loop over an array is not yet understood by me. the nested parenthesis, the # for some reason, what is @

@vaporeon_ @aescling whitespace matters a lot which is surprising coming from c-style languages

like I tried to do if [! -d $dirname]; then and bash got mad at me for not putting a space between [ and !

@wallhackio @aescling Yeah, that is confusing coming from C-style languages
If you type [!, instead of invoking a command [ with the arguments ! -d $dirname], it tries to invoke a command [!, which does not exist...

Do not run this on your computer 

@wallhackio @aescling Is Clodsire familiar with this invocation?

:(){ :|:& };:

re: Do not run this on your computer 

@wallhackio @vaporeon_ @aescling who up forking they bomb

@vaporeon_ @wallhackio @aescling it looked to me like there was whitespace there so my dumb ass was staring at it trying to figure out why this would happen

@cam @wallhackio @aescling Sorry, I was specifically talking about [!, no whitespace in between, as opposed to [ !, yes whitespace in between...

@vaporeon_ @wallhackio @aescling it’s not your fault, I didn’t realize it was in monospace font so I was expecting it to look like [!

@wallhackio @vaporeon_ [ is an alternative name of the command test(1); it needs to be recognized as its own token

@wallhackio @aescling man bash, type /Parameter Expansion, scroll down a little, and find out that ${#parameter} will get the length of parameter, especially:

If parameter is an array name subscripted by * or @, the value substituted is the number of elements in the array.

There is some difference between @ and *, but I keep forgetting it myself :(

@wallhackio @vaporeon_ this is bash-specific territory, where many features are added and language complexity explodes. there are nice conveniences but the funkiness of the language on top of the already funky nature of POSIX shell makes me want to avoid it where pawsible

@aescling @wallhackio Stupid question: Does POSIX shell have parameter expansions?

@vaporeon_ @wallhackio yes but not all of bash’s fancy expansions. you definitely do not have arrays lol

@vaporeon_ @wallhackio basic parameter expansion was in the original Bourne shell; i would have been shocked if some take on it hadn’t been standardized

@wallhackio @vaporeon_ anyway

purr the Pure Bash Bible, the double parentheses are an alternate C-style syntax fur for loops with apparently similar semantics

@wallhackio @aescling As I understand it, this is the expected state of Bash shell scripting.

@wallhackio @aescling I hate the syntax and it seems like there's absolutely no good reason for it *until* you realize that most of it initially wasn't actually a shell builtin, and there was literally a binary at `/usr/bin/[` (and depending on what you use for coreutils / etc., may still be). At which point it makes a *touch* more sense, though it may also make you wonder why more people haven't moved to scripting with better syntax now that hard drives aren't measured in the tens of megabytes.

Sign in to participate in the conversation
📟🐱 GlitchCat

A small, community‐oriented Mastodon‐compatible Fediverse (GlitchSoc) instance managed as a joint venture between the cat and KIBI families.