Тёмный

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

You Suck at Programming
Подписаться 1,5 тыс.
Просмотров 1,5 тыс.
50% 1

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

Наука

Опубликовано:

 

10 май 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 14   
@extrageneity
@extrageneity 23 дня назад
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 18 дней назад
Hi, I wanted to read #7 comment but it's not there
@DeusExEllimist
@DeusExEllimist 23 дня назад
Huh, that was super cool! Loving the vids.
@dave7244
@dave7244 22 дня назад
Great video. Been using the terminal for a while and didn't know this.
@Sleep4Week
@Sleep4Week 23 дня назад
You had me at hello world
@rajmajumdar5253
@rajmajumdar5253 21 день назад
Damn I have an exam where this will be asked , really thanks bro.
@yousuckatprogramming
@yousuckatprogramming 17 дней назад
that’s awesome that you’re learning bash in your studies #bash #programminglanguage
@skilletpan5674
@skilletpan5674 23 дня назад
What about ansi macros? That makes things even more complicated... or is it fun?
@BenjaminWheeler0510
@BenjaminWheeler0510 23 дня назад
So why do all these builtins exist? Is it because they’re faster than the bin equivalents?
@asaf92
@asaf92 22 дня назад
And they don't require a new process, there's an example in one of the other videos
@RazoBeckett.
@RazoBeckett. 23 дня назад
Yo my name is Razo and i suck at programming
@ZoinkDoink
@ZoinkDoink 22 дня назад
these videos are too based. 10k subs by the end of the year calling it now
@yousuckatprogramming
@yousuckatprogramming 22 дня назад
the terminal is your friend #bash #programminglanguage #unix
Далее
I Rewrote My Entire Neovim Config...
11:09
Просмотров 32 тыс.
skibidi toilet multiverse Special Episode 02
07:37
Просмотров 4,5 млн
Китайка и Пчелка 4 серия😂😆
00:19
simple neovim debugging setup (in 10 minutes)
9:36
Просмотров 21 тыс.
КАК GOOGLE УКРАЛ ANDROID?
17:44
Просмотров 84 тыс.
ПК с Авито за 3000р
0:58
Просмотров 1,7 млн