[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Logical expression works does not work as expected
From: |
Павел Fortovey |
Subject: |
Re: Logical expression works does not work as expected |
Date: |
Sat, 28 Dec 2024 00:52:59 +0300 |
I apologize. I found out that this behavior is not a bug.
I didn't think that bash is such a strange scripting language with its
own interpretation of the concept of logic.
21:54, 27 декабря 2024 г., "Павел Fortovey" <fortovey@ya.ru>:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -g -O2 -fstack-protector-strong -Wformat
-Werror=format-security -Wall
uname output: Linux pve-lab 6.8.12-5-pve #1 SMP PREEMPT_DYNAMIC PMX
6.8.12-5 (2024-12-03T10:26Z) x86_64 GNU/Linux
Machine Type: x86_64-pc-linux-gnu
Bash Version: 5.2
Patch Level: 15
Release Status: release
Description:
in a logical expression of the form "true && true || false &&
false" the first two are executed, but unexpectedly the last value
"false" is executed. i.e. the command "printf 1 && printf 2 || printf 3
&& printf 4" will give "124" instead of the expected answer "12"
Repeat-By:
bash -c "true && true || false && echo bug"
--
Отправлено из мобильного приложения Яндекс Почты