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
«جنگ ایران» دگربار نشان داد که تکنولوژی بهتنهایی نمیتواند ژئوپلیتیک را رام سازد و مهار کند. میدان نبرد نه تنها با جنگافزارهای مدرن، بلکه با جغرافیا نیز تعیین میشود. سرنوشت این جنگ چه بسا ممکن است سرانجام به دو گلوگاه ژئوپلیتیکی گره بخورد: تنگه هرمز و بابالمندب.
#IranWar
A War Without a Clear Exit: Iran, the United States, and Israel at Week Five. Read more.
https://borkena.com/2026/04/05/iran-war-a-war-without-a-clear-exit-iran-the-united-states-and-israel-at-week-five/#Iran#Iranwar#usa
🚨🇺🇸TRUMP WEIGHS MASSIVE TROOP SURGE TO IRAN WAR ZONE
🔹 Pentagon considers deploying THOUSANDS more troops as Iran conflict hits day 37 — biggest Middle East buildup since Iraq 2003 ⚔️
🔹 Already ordered: 2,500 Marines aboard USS Tripoli heading to Strait of Hormuz for uranium seizure mission 🚢
🔹 Target: 900 pounds Iranian enriched uranium buried deep underground — Trump calls operation 'very dangerous' 💣
🔹 Public support TANKING: Only 25% of Americans back this war, Pentagon officials dispute intelligence justification 📊
Largest US military presence in Middle East since Bush era — but is America ready for another ground war? 🔥💀
#USNews#IranWar#breaking
@america
Trump says “I agree to suspend the bombing and attack of Iran” Read more.
https://borkena.com/2026/04/07/trump-says-i-agree-to-suspend-the-bombing-and-attack-of-iran/#Trump#Iran#IranWar#iranwar@realDonaldTrump#usa
Guess what?! Roaming through American IT market led us to an Israeli company called Netvision. I took the company details from the web. As you can see, Bushnell's poster was on the printing queue three times. And do not forget, while we are watching all these posts, Iranians are getting killed by peace-bringing bombs from above. 💔
#bushnell
#Iranwar
#Israel
🚨📊TRUMP APPROVAL HITS IRAN WAR LOW — 40% AS GAS SOARS
🔹 Trump approval drops to 40-42% in new March polls — lowest since Iran war began 🇺🇸🇮🇷
🔹 Gas prices surge to $3.96/gallon after Iran blocks Hormuz Strait — up 35% in one month ⛽💰
🔹 Only 38% approve of his Middle East handling while 67% slam cost-of-living response 📈📉
🔹 $100 fill-ups now reality as oil hits $100/barrel — analysts say no relief until mid-2027 😤⛽
🔹 92% of MAGA base still supports Iran strikes but independents demand quick exit strategy 🎯🚁
The pump prices are KILLING his numbers — even loyal voters feeling the pinch 💸🔥
#USNews#TrumpPolls#IranWar
@america
God Save Ethiopia from the Gulf War: The Mechanics of a Fuel-Driven State Collapse. Read more.
https://borkena.com/2026/04/07/god-save-ethiopia-from-the-gulf-war-the-mechanics-of-a-fuel-driven-state-collapse/#Ethiopia#IranWar#fuel