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
🎄✨ Celebrate the joy of the season with Loot Baba [Official]!🎉
Wishing you a magical Merry Christmas 2025🎅 and a prosperous New Year ahead! ⭐️💎
Let’s welcome the future with endless opportunities and happiness! 🎁🔥
#merrychristmas@LootBaba_Officiall
Wishing all Nigerians a healthy and joyful Christmas! 🎄
May the spirit of the season bring happiness and well-being to your homes.
Stay safe, cherish moments, and embrace the gift of good health.
#MerryChristmas!🎄🎄
🇮🇩 Public Holidays in Bali
🎅 December 25 and 26 are official public holidays across Indonesia.
On these days, government institutions will be closed (including banks, tax offices, municipal offices, and other public services).
#MerryChristmas@BaliNews
¡Ay papá! Se acerca el #24Dic y lo que viene es rumba. Salí con Cilita a dar un recorrido por las calles de Caracas, vimos las fiestas navideñas; nuestro Pueblo está ejerciendo el derecho más bonito que tiene: el de la felicidad, vivir en Paz y disfrutar de este tiempo de unión. “¡No War!” #MerryChristmas
«Эта ночь принадлежит кроткому, посему пусть каждый отложит ярость и суровость, – принадлежит смиренному, пусть каждый обуздает свою гордость и смирит свое высокомерие. Ныне воссиял день милости, да не преследует же никто мщением нанесенной ему обиды; настал день радости, да не будет же никто виною печали и скорби для другого». (Ефрем Сирин. Слово на Рождество Христово). #καλαχριστουγεννα#merrychristmas
🎄✨ Merry Christmas from SingSing! 🎄✨
As the year comes to a close, we want to take a moment to express our heartfelt gratitude to our incredible SingSing community. 💖 Your unwavering support, enthusiasm, and passion have been the driving force behind everything we’ve accomplished together this year.
From building a thriving ecosystem to launching exciting games and features, none of this would have been possible without YOU. 🌟
🎁 This holiday season, we wish you and your loved ones endless joy, peace, and togetherness. May your days be filled with laughter, love, and the magic of Christmas. 🎅
Here’s to an even brighter and more exciting year ahead! Together, we’ll continue to grow, achieve, and make SingSing the #1 platform for all. 🚀
With love and gratitude,
The SingSing Team 💎
#SingSing#MerryChristmas#HappyHolidays
🎅Дорогие подписчики Легкого Неба!
🎉От лица руководства канала мы поздравляем вас с 2026 годом, желаем вам счастья, здоровья и главное - чистого и Лёгкого неба над головой!
🎅Надеемся, совсем скоро дед Мороз прилетит по Лёгкому небу к вам!
❄️Happy New Year!
Команда Легкое Небо
#merrychristmas#newyear#happy