reload_flag=""
if [[ -n "${DEBUG}" ]]; then
reload_flag="--reload"
fi
if [[ -n "${WORKER_COUNT}" ]]; then
workers=${WORKER_COUNT}
else
workers=2
fi
gunicorn --workers ${workers} \
--bind 0.0.0.0:8000 \
${reload_flag} main.wsgi
Писали такие конструкции чтобы проверить наличие флага и сформировать команду правильно?
На самом деле можно сделать тоже самое проще. Для этого используются операторы условной подстановки, доступные в оболочках семейства POSIX.
:- для установки значений по умолчанию
${WORKER_COUNT:-2}
Если переменная не объявлена, то будет дефолтное значение 2.
:+ подставляет указанный текст, если переменная не пуста
${DEBUG:+--reload}
Если что-то есть в переменной то распечатается текст после символа +, в противном случае - ничего. Удобно для опциональных флагов, как в нашем примере.
Итого наш скрипт может выглядеть так:
gunicorn --workers ${WORKER_COUNT:-2} \
--bind 0.0.0.0:8000 \
${DEBUG:+--reload} main.wsgi
Есть еще два оператора.
:= не только подставить дефолтное значение, но и присвоить его переменной, если она пуста
# никаких переменных еще нет
VAL1=${VAL2:=hello}
# теперь доступны обе
echo $VAL1 $VAL2
# hello hello
:? остановить выполнение с ошибкой, если переменной нет.
echo ${MISS:?is required}
bash: MISS: is required
Код выхода будет 1.
#tricks#linux
📰 Steam Client Beta bring fixes for the new Linux SteamRT3 Beta
Valve released a fresh update to the Steam Client Beta, bringing a few useful bug fixes and more work on the new Linux SteamRT3 Beta.Read the full article on GamingOnLinux.
🔗 Source: https://www.gamingonlinux.com/2026/03/steam-client-beta-bring-fixes-for-the-new-linux-steamrt3-beta/
#steam#linux
📰 Proton Experimental brings fixes for Crimson Desert, Steam Overlay with EA games, Death Stranding 2
Valve just pushed out another excellent update for Proton Experimental - further improving Windows games running on Linux / SteamOS.Read the full article on GamingOnLinux.
🔗 Source: https://www.gamingonlinux.com/2026/03/proton-experimental-brings-fixes-for-crimson-desert-steam-overlay-with-ea-games-death-stranding-2/
#steam#linux
📰Steam Linux Beta Prepares For 64-bit, Can Be Run Inside Steam Runtime Container
An interesting new Steam client beta dropped overnight from Valve with some exciting low-level enhancements...
🔗 Source: https://www.phoronix.com/news/Steam-Linux-Beta-In-Container
#linux#steam
📰 Unity announce expanded supported for Steam, Native Linux, Steam Deck and Steam Machine
For GDC 2026, Unity revealed expanded official support is coming for Steam. This includes Native Linux, Steam Deck, Steam Machine and more.Read the full article on GamingOnLinux.
🔗 Source: https://www.gamingonlinux.com/2026/03/unity-announce-expanded-supported-for-steam-linux-steam-deck-and-steam-machine/
#steam#linux
📰 I'm Low-key Hyped for This Data Center Sim (Though It Has No Official Linux Support)
There's a free demo up on Steam right now, and I took it for a spin.
🔗 Source: https://itsfoss.com/data-center-game/
#steam#linux
📰 Lutris 0.5.21 Adds Steam Sniper Runtime and New Console Emulators
Lutris 0.5.21 introduces support for Valve’s Sniper runtime, adds ShadPS4 and Xenia runners, and improves GPU detection on Linux systems.
🔗 Source: https://linuxiac.com/lutris-0-5-21-adds-steam-sniper-runtime-and-new-console-emulators/
#linux#steam
📰 After 6 Years, One of Wayland’s Most Annoying Problems is Finally Getting Fixed
The new xdg-session-management protocol finally brings session saving and restoration to Wayland, eliminating a long-standing annoyance for Linux users and paving the way for a smoother desktop experience.
🔗 Source: https://feed.itsfoss.com/link/24361/17308544/wayland-session-management
#wayland#linux
📰Foot: The Wayland Terminal Most Linux Users Don’t Know About
Foot is a minimal Wayland-native terminal emulator for Linux that focuses on speed and simplicity. A hidden gem worth exploring.
🔗 Source: https://feed.itsfoss.com/link/24361/17298790/foot-terminal
#linux#wayland
📰 NVIDIA 595.45 Beta Linux Driver Released With Vulkan Updates and Wayland Changes
NVIDIA has released the 595.45 beta Linux driver, featuring new Vulkan extensions, Wayland updates, DRI3 1.2 support, and several stability improvements.
🔗 Source: https://linuxiac.com/nvidia-595-45-04-beta-linux-driver-released/
#wayland#linux
📰 NVIDIA 595.45 Beta Linux Driver Released With Vulkan Updates and Wayland Changes
NVIDIA has released the 595.45 beta Linux driver, featuring new Vulkan extensions, Wayland updates, DRI3 1.2 support, and several stability improvements.
🔗 Source: https://linuxiac.com/nvidia-595-45-04-beta-linux-driver-released/
#wayland#linux
📰 Linux Mint Previews Native Cinnamon Screensaver With Wayland Support
Linux Mint introduces a native Cinnamon screensaver with Wayland support and adds a sensors page to System Reports.
🔗 Source: https://linuxiac.com/linux-mint-previews-native-cinnamon-screensaver-with-wayland-support/
#linux#wayland