| Post Reply | RetroFed Forums Forum Index » Shell Scripting |
| Author | Message | ||
|---|---|---|---|
|
Ballig
programming.dev
Ballig@programming.dev Joined: 2024-02-26 |
I've written small bash scripts before, but I bit off a little more this time, and I'm trying to program a little terminal game. Anyway, I've run into a weird behavior. I have a function that, among other things, writes values to an array and returns either 0 or 1. If I write If I write But if I write the following, regardless of which value the function returns, nothing is printed to standard output but an empty line.
Why is that the case? Doesn't name_of_function get executed when evaluating the if statement? Is this some special case where all variables become local? I realize I could just assign the function's return value to a separate variable and then use that variable as the condition to the if statement, but it's less elegant, and it doesn't satisfy my curiosity. Is there any way to get the array out of the if statement alone? It's also possible I'm an idiot and my problem is just some random punctuation somewhere. |
||
| 1 Original | |||
| Post Reply |
Back to top |