No video

Command Substitution: Can you return data instead of exit codes in Bash? | #3 Practical Bash

  Рет қаралды 10,904

kubucation

kubucation

Күн бұрын

It seems bash only allows us to return an exit code from a function and not data like in other programming languages? So what do we instead? Can command substitution come to the rescue? In this video you'll learn how to safely pass data from one function in your script to another

Пікірлер: 14
@bernhardkern629
@bernhardkern629 4 жыл бұрын
yay, my first youtube comment, just to tell you that your video series is great. Watched the https/tls video and landed in your bash series.
@kubucation
@kubucation 4 жыл бұрын
Thanks! I feel honored to receive your first ever youtube comment :-)
@ernestogutierrez7877
@ernestogutierrez7877 3 жыл бұрын
Had I known function return statements where meant for returning exit codes (0-255) back when I started coding bash scripts, I would have saved myself a lot of troubleshooting time :S Great video mate!
@soufianta8374
@soufianta8374 Жыл бұрын
Hi, this is one of the weird things I took time to understand. Actually, bash shouldn’t be compared to other languages (data types). Bash was supposed to run external binaries/commands that do their stuff and binaries don’t need to play with return values of other binaires. Nice video btw
@mithunmanoharmithun
@mithunmanoharmithun 4 жыл бұрын
This series is awesome. Thanks !
@jamesw6949
@jamesw6949 4 жыл бұрын
Introduced me to shellcheck, thanks!
@kubucation
@kubucation 4 жыл бұрын
And you just gave me the idea to create a video about shellcheck. Thanks :)
@jamesw6949
@jamesw6949 4 жыл бұрын
@@kubucation :)
@blank-vw2sb
@blank-vw2sb 2 жыл бұрын
Love the series. Thanks!!
@VoltVandal
@VoltVandal 5 жыл бұрын
thanks, very understandable
@kubucation
@kubucation 5 жыл бұрын
thanks a lot, very glad to hear :)
@loveanimals-0197
@loveanimals-0197 4 жыл бұрын
What if you had multiple echo statements within that called function?
@kubucation
@kubucation 4 жыл бұрын
All output that is usually sent to stdout would be caught. A single or multiple echo statements don't make a difference. We only see an echo statement as a "unit" because it automatically appends a new line ( ) at the end of the line. However, that's just a default setting and you can in fact not add a new line by using "echo -n foo". Similarly the new line would just be caught by the command substitution along with the remaining output.
@fuseteam
@fuseteam 4 жыл бұрын
part 3?
You don't know Bash as well as you think
30:35
glich.stream
Рет қаралды 1,2 М.
ISSEI & yellow girl 💛
00:33
ISSEI / いっせい
Рет қаралды 22 МЛН
7 Days Stranded In A Cave
17:59
MrBeast
Рет қаралды 85 МЛН
Please Help Barry Choose His Real Son
00:23
Garri Creative
Рет қаралды 22 МЛН
grep: All you need to know | #6 Practical Bash
11:14
kubucation
Рет қаралды 19 М.
EVERYONE Needs to Learn a Little Bit of AWK!
16:29
Gary Explains
Рет қаралды 397 М.
BASH scripting will change your life
14:18
NetworkChuck
Рет қаралды 1 МЛН
Learning Awk Is Essential For Linux Users
20:02
DistroTube
Рет қаралды 294 М.
Write Your Own Bash Scripts for Automation [Tutorial]
16:35
Null Byte
Рет қаралды 760 М.
Let's Write A Script! | How To Create BASH Scripts In Linux
49:45
ISSEI & yellow girl 💛
00:33
ISSEI / いっせい
Рет қаралды 22 МЛН