Unix Shell Builtins vs. External Commands - You Suck at Programming

  Рет қаралды 1,434

You Suck at Programming

You Suck at Programming

19 күн бұрын

You Suck at Programming
Website → ysap.daveeddy.com
#programming #devops #bash #linux
#unix #software #terminal #shellscripting #tech #stem

Пікірлер: 14
@extrageneity
@extrageneity 17 күн бұрын
Episode 8 - Unix Shell Builtins vs. External Commands Key concepts from this episode: - Demonstration of working interation between aliases, functions, shell builtins, and external commands. - Use of the type command to get an explanation of how bash resolves a given simple command. I actually covered most of this already in my comment from Episode 7. Rather that completely re-iterating everything from that comment, I'll instead give some errata here. 1. General errata. - The four command types Dave enumerated as possible resolutions by bash are the four categories of "simple command" that bash knows how to execute. You can get a single-word descriptor of which command type bash will resolve a word to by doing 'type -t '. See 'help type' for the possible answers. - Dave shows the 'which ' command as the best way to see which executable bash would execute out of $PATH. In my opinion this is very slightly cringe; modern bashes give 'type -P ' and 'type -Pa ', which respectively dump the first executable from $PATH matching the word, and all executables from $PATH, one per line. This doesn't just save a fork, it also benefits from cases where your current $PATH will change in the shell executed by the `which` command, which might not even be bash depending on your system. 2. alias errata. - 'shopt -s expand_aliases' is required to make aliases work inside your scripts. Without this, they only function in interactive shells. - \ (preceding a word with a bashslash) will bypass any alias corresponding to that word. 3. builtin errata. - Bash provides builtins called 'enable' and 'disable' which can be used to enable or disable certain bash builtins at runtime. If you want an executable to win out over a builtin with the same name, and don't want to give the path to the executable, disabling the builtin is one option. - Using enable, it's possible to load builtins that are not part of bash itself, via dynamic linking and the BASH_LOADABLES_PATH environment variable. If Dave ever gets to talking about this in YSAP, I probably won't comment because that's way out of my depth, but Googling on the subject just now you can apparently write the builtins in Rust using a crate called bash_builtins. That might scratch some of you in spots you didn't know you were itching. - Bash documentation divides builtins into two broad categories, 'bash builtins' and 'bourne shell builtins'. It's worth educating yourself as to which is which. Unixes with non-bash shells get more and more rare but you do still occasionally encounter them, especially if you work with embedded systems and rackable appliances. The best place to read about the differences between these is in the Bash Reference Manual, which you can find at www.gnu.org/software/bash/manual/bash.html or by running 'info bash' on many bash installations. (Chapter 4 as of this writing.) - Also slightly cringe in Dave's example, he wants to access the echo builtin from inside a function but does this with 'command' which can match either a builtin or an external command, instead of using 'builtin' which explicitly resolves to a builtin. External commands and functions are both going to be covered more in later episodes so I'll skip errata for those for today. Happy scripting!
@killua_148
@killua_148 11 күн бұрын
Hi, I wanted to read #7 comment but it's not there
@DeusExEllimist
@DeusExEllimist 17 күн бұрын
Huh, that was super cool! Loving the vids.
@Sleep4Week
@Sleep4Week 17 күн бұрын
You had me at hello world
@dave7244
@dave7244 16 күн бұрын
Great video. Been using the terminal for a while and didn't know this.
@rajmajumdar5253
@rajmajumdar5253 14 күн бұрын
Damn I have an exam where this will be asked , really thanks bro.
@yousuckatprogramming
@yousuckatprogramming 11 күн бұрын
that’s awesome that you’re learning bash in your studies #bash #programminglanguage
@skilletpan5674
@skilletpan5674 17 күн бұрын
What about ansi macros? That makes things even more complicated... or is it fun?
@BenjaminWheeler0510
@BenjaminWheeler0510 16 күн бұрын
So why do all these builtins exist? Is it because they’re faster than the bin equivalents?
@asaf92
@asaf92 16 күн бұрын
And they don't require a new process, there's an example in one of the other videos
@RazoBeckett.
@RazoBeckett. 16 күн бұрын
Yo my name is Razo and i suck at programming
@ZoinkDoink
@ZoinkDoink 16 күн бұрын
these videos are too based. 10k subs by the end of the year calling it now
@yousuckatprogramming
@yousuckatprogramming 16 күн бұрын
the terminal is your friend #bash #programminglanguage #unix
Debugging Bash using DTrace - You Suck at Programming #006
2:14
You Suck at Programming
Рет қаралды 1,1 М.
Piping `find` to `while` - You Suck at Programming #004
3:07
You Suck at Programming
Рет қаралды 1,8 М.
NO NO NO YES! (50 MLN SUBSCRIBERS CHALLENGE!) #shorts
00:26
PANDA BOI
Рет қаралды 101 МЛН
How I prepare to meet the brothers Mbappé.. 🙈 @KylianMbappe
00:17
Celine Dept
Рет қаралды 48 МЛН
NixOS: Everything Everywhere All At Once
15:10
No Boilerplate
Рет қаралды 253 М.
The Absolute Best Intro to Monads For Software Engineers
15:12
Studying With Alex
Рет қаралды 556 М.
Parsing arguments in bash - You Suck at Programming #002
1:37
You Suck at Programming
Рет қаралды 979
You Should Read the `bash` manpage - You Suck at Programming #007
2:28
You Suck at Programming
Рет қаралды 1,5 М.
Bash vs ZSH vs Fish: What's the Difference?
13:32
Eric Murphy
Рет қаралды 150 М.
simple neovim debugging setup (in 10 minutes)
9:36
TJ DeVries
Рет қаралды 19 М.
Why Linux is better for (most) developers!
14:59
The Linux Experiment
Рет қаралды 459 М.
Config Files with Bash can be Dangerous - You Suck at Programming #010
2:06
You Suck at Programming
Рет қаралды 890
Dear Functional Bros
16:50
CodeAesthetic
Рет қаралды 445 М.
Compiled Python is FAST
12:57
Doug Mercer
Рет қаралды 86 М.
Готовый миниПК от Intel (но от китайцев)
36:25
Ремонтяш
Рет қаралды 455 М.
⌨️ Сколько всего у меня клавиатур? #обзор
0:41
Гранатка — про VR и девайсы
Рет қаралды 647 М.
Kalem ile Apple Pen Nasıl Yapılır?😱
0:20
Safak Novruz
Рет қаралды 884 М.