No video

I'm BREAKING UP With Bash (Using dash as /bin/sh)

  Рет қаралды 5,570

Eric Murphy

Eric Murphy

Күн бұрын

Are you tired of having your shell scripts run by the slow, bloated bash? In this video, I'll show you how you can change your system shell (/bin/sh) to dash for minimal performance and security gains-and, more importantly, how to write better shell scripts that are portable, posix-compliant and usable by everyone, not just bash users.
Article on checking for Bashisms and testing with Dash: dev.to/bowmanj...
Dash article in the Arch Wiki: wiki.archlinux...
Watch my videos on Odysee: odysee.com/@er...
My website: ericmurphy.xyz
My GitHub: github.com/eri...
0:00 Intro
1:14 Differences between bash and dash
2:35 Installing dash
2:45 Checking /bin/sh scripts to remove bashisms
6:23 Making your scripts dash-compliant
7:40 Or just set bash scripts explicitly with /bin/bash
9:02 Using shellcheck for even more detail
10:00 Symlinking /bin/sh to dash
10:41 Relinking dash every time bash updates
11:45 Conclusion

Пікірлер: 21
@softwarecitadel
@softwarecitadel Жыл бұрын
I highly dislike both bash and dash, I prefer cash. Aside from the joke, thanks for this video ;) Cheers from France !
@user-il4ux8ml5p
@user-il4ux8ml5p Жыл бұрын
hatred from the uk
@MisterConscio
@MisterConscio Жыл бұрын
9:22 On the shellcheck command output, if you follow that link, it will open a page where it give code examples on how to replace arrays.
@EricMurphyxyz
@EricMurphyxyz Жыл бұрын
That's why I prefer using shellcheck as opposed to checkbashisms, the wiki it links to is very useful
@saumitit944
@saumitit944 Жыл бұрын
I tried to do this thing few months back. However, I switched back to having bash as my default shell for the following reasons: 1) I run linux natively on pretty modern hardware, so there really is not much overhead provided by bash compared to dash. It may be few milliseconds faster, but for me, it's not even noticeable. 2) First point, doesn't really justify not switching because it's neither a positive nor a negative for me to change, However, I use some scripts using dmenu, which use non-posix compliant bashism or some "bloat" in form of extra flags in gnuutils which aren't recognized by dash. Took me a while to figure out some of it, learned about POSIX shell and that bashisms aren't just limited to shell but also gnuutils. Like how BSD echo is different from GNU echo and so on. ... For example, echo -e "up\down\connect" | dmenu in bash gives (using "|" as separations of the different options) up | down | connect ✅✅ in dash gives -e up | down | connect ❌❌ ... So simple thing right? just replace the -e flag with something standard... like just use echo "up \down connect" | dmenu if you run a script having this in dash it'd produce up | down | connect ✅✅ HOWEVER, now Bash breaks it?? giving up down connect ❌❌ as one single option ... At last, I ended up switching from simple echo to printf just to pipe the output to dmenu. I saw luke smith's video on GNU is bloated and then Brodie's video on POSIX and just got to terms with using bash as my system shell. If I were handling an enterprise-grade server running linux, where security is paramount, I would switch the system shell to dash(if it already isn't) else for my personal computer where threat model is alright I would just stick to using bash. ... If you wish to check whether your script would run in dash without having to reboot your computer over and over again and checking if it breaks or not (totally not me lol) just use shellcheck --shell=dash
@danny.cuevas
@danny.cuevas Жыл бұрын
Beautiful videos man, pretty well edited, and content is pretty good as well!, I am subscribed!. Quick question, do you have any videos-tutorials on how did you tune-up your terminal and OS to look that way? everything looks so comfy and elegant! Cheers from Mexico City (:
@EricMurphyxyz
@EricMurphyxyz Жыл бұрын
I do have some old videos on my terminal setup, here's one for my terminal prompt: kzfaq.info/get/bejne/hb57m9lj176wcqM.html I will make some videos on setting up bspwm and how I make my OS look like this in the future, so stay tuned!
@danny.cuevas
@danny.cuevas Жыл бұрын
@@EricMurphyxyz sounds great, I will be waiting! XD and thank you
@thedeathchimera
@thedeathchimera Жыл бұрын
For a non-posix shell I'd reccomend Elvish. Had a lot of fun writing scripts with it (not a system shell though).
@joaopauloalbq
@joaopauloalbq Жыл бұрын
How bad is writing POSIX-Compliant shell scripts?
@EricMurphyxyz
@EricMurphyxyz Жыл бұрын
From my experience? It's not really that bad if you write it from the start as POSIX shell compliant, but if you try to rewrite a large bash script it can be a nightmare. Some scripts are just easier to do with bash, but there's usually a workaround
@laughingvampire7555
@laughingvampire7555 11 ай бұрын
my issue about this is that bash is the default shell in most of the distros so if you are going to install another scripting runtime then you should better write your scripts in a decent scripting language that doesn't have the context-switching mess of shell scripting and use perl, python, lua, ruby, guile, etc.
@f_aaris
@f_aaris Жыл бұрын
Great video but sadly dash was causing quite a few issues for me so won't be using it for now. Maybe in the future it'll be a viable alternative or maybe even the recommended program for a /bin/sh
@EricMurphyxyz
@EricMurphyxyz Жыл бұрын
What kind of issues? I'm curious
@f_aaris
@f_aaris Жыл бұрын
@@EricMurphyxyz I was able to fix some but I'm also using zgenom and I seem to get a lot of bashisms with the plugins and the autoupdater and stuff. I could manually change them to bash but since they're coming from a git repo I'd rather not
@laughingvampire7555
@laughingvampire7555 11 ай бұрын
ubuntu is pronounced oo-boon-too, not you-bun-too
@ade5324
@ade5324 Жыл бұрын
alternative title: Bash is Trash
@EricMurphyxyz
@EricMurphyxyz Жыл бұрын
That's a good one
@nico1337
@nico1337 Жыл бұрын
I use the AUR package dashbinsh. pfetch hostname works fine for me. (pfetch-git from AUR). And my scripts use "#!/usr/bin/env bash"
@EricMurphyxyz
@EricMurphyxyz Жыл бұрын
Guess I don't have the latest version of pfetch. I should have mentioned that #!/usr/bin/env bash is more portable, that's what I use when I write bash scripts
Stay on your way 🛤️✨
00:34
A4
Рет қаралды 31 МЛН
Sunglasses Didn't Cover For Me! 🫢
00:12
Polar Reacts
Рет қаралды 5 МЛН
SPILLED CHOCKY MILK PRANK ON BROTHER 😂 #shorts
00:12
Savage Vlogs
Рет қаралды 43 МЛН
EVOLUTION OF ICE CREAM 😱 #shorts
00:11
Savage Vlogs
Рет қаралды 14 МЛН
Why POSIX shell scripts? [20210310161500]
23:18
rwxrob
Рет қаралды 2,1 М.
What Kinds of Files Can Be Viruses?
14:08
ThioJoe
Рет қаралды 251 М.
I forced EVERYONE to use Linux
22:59
NetworkChuck
Рет қаралды 346 М.
Shell Tricks to Save Time in Linux
10:42
Mental Outlaw
Рет қаралды 43 М.
Bash function fun, who needs ZSH when you can just do this.
18:31
Nobody Understands Online Privacy.
14:11
Eric Murphy
Рет қаралды 178 М.
Why Do I Care So Much About Privacy?
15:30
Eric Murphy
Рет қаралды 258 М.
Why Do I Shill Arch Linux So Much?
10:18
Eric Murphy
Рет қаралды 107 М.
Why Are Open Source Alternatives So Bad?
13:06
Eric Murphy
Рет қаралды 607 М.
How Google's Chromium Took Over the Browser World
9:59
Eric Murphy
Рет қаралды 276 М.
Stay on your way 🛤️✨
00:34
A4
Рет қаралды 31 МЛН