On 2/12/22 1:24 PM, David Hobach wrote:
I guess 99% of programmers would either expect "Finished" to be printed
or some syntax error.
Well, 99% of shell programmers will (hopefully ;-) ) put a blank between
"{" and "echo" in the line
foo="$(testCode)" || {echo "foo";}
Yes, the interesting
On 2/12/22 5:20 PM, David Hobach wrote:
Thanks a lot for the detailed explanations, much appreciated!
So essentially it's no bug - just a rather uncommon choice of keywords.
I still don't agree with that choice since it can be abused to somewhat
hide code in pull requests to less experienced m
Thanks a lot for the detailed explanations, much appreciated!
So essentially it's no bug - just a rather uncommon choice of keywords.
I still don't agree with that choice since it can be abused to somewhat hide
code in pull requests to less experienced maintainers, but oh well... there's
proba
On Sat, Feb 12, 2022 at 8:25 PM David Hobach wrote:
> I guess it closes the function and {echo is interpreted as string or so,
> but that is probably not all (testCode is e.g. never executed).
>
Let's see if I get this right.
Removing the irrelevant parts, your code is pretty much this:
func()
Hi David!
> A syntax error would be nice instead.
I see - also from you second answer - that you have some fundamental
misunderstandings about shell programming:
- Your code will, in case the testCode fails, try execute a program called
{echo. This is certainly not a good name for a program, b
On Feb 12 2022, David Hobach wrote:
> Yes, the interesting part is that depending on which space you accidentally
> forget, you'll either get the expected "Finished" or "bad code executed".
> foo="$(testCode)" || {echo "foo"; } # --> bad code
> foo="$(testCode)" || { echo "foo";} # --> Finished
P.S.: Also, if you remove the case/esac from the original example, it'll result
in a syntax error. So why can the case/esac be used to ignore the syntax error?
smime.p7s
Description: S/MIME Cryptographic Signature
I guess 99% of programmers would either expect "Finished" to be printed or some
syntax error.
Well, 99% of shell programmers will (hopefully ;-) ) put a blank between "{" and
"echo" in the line
foo="$(testCode)" || {echo "foo";}
Yes, the interesting part is that depending on which space you
On 12/02/2022 at 12:23, David Hobach wrote:
function tfunc {
local foo=
foo="$(testCode)" || {echo "foo";}
^ Missing space after opening brace
Because the code block is missing a space after the opening brace; the
opening brace is ignored, but the following cl
Hello David!
> I guess 99% of programmers would either expect "Finished" to be printed or
> some syntax error.
Well, 99% of shell programmers will (hopefully ;-) ) put a blank between "{"
and "echo" in the line
foo="$(testCode)" || {echo "foo";}
Best regards
Martin
10 matches
Mail list logo