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
3 hours ago, James Fickel (@jamesfickel) swapped another 350 $WBTC for 6,905 $ETH ($24.4M) at ~$3,534 as the $ETH price soared 20% (24H)!
Note that since Dec 30, 2023, the founder of Amaranth Foundation has been bullish on the ETH/BTC trading pair, borrowing and exchanging 2,741 $WBTC for 50,688 $ETH at an ETH/BTC ratio cost of 0.054.
Follow @spotonchain and visit James Fickel’s address at https://platform.spotonchain.ai/en/profile?address=0xd85351181b3f264ee0fdfa94518464d7c3defada
#EthereumETF#Approval
📊🇺🇸TRUMP APPROVAL RATING HITS 37% AS WAR DRAGS ON
🔹 Latest Pew Research poll shows Trump at 37% approval - down from 40% last fall 📉
🔹 365 straight days of negative approval ratings since March 2025 📅
🔹 No "rally around flag" bump despite Iran military strikes last week ⚔️
🔹 50% of Americans say administration performing WORSE than expected vs only 21% better 😬
🔹 Even Republican support drops to 73% - lowest since second term began 🔴
🔹 G. Elliott Morris analysis shows Trump stuck at 39-40% with no upward momentum 📈
War usually boosts presidents but NOT this time - Americans want results! 🇺🇸💯
#polls#approval#Trump
@america
📉🇺🇸TRUMP APPROVAL CRASHES TO 37% AMID IRAN WAR
🔹 Approval rating drops to 37% in latest Pew poll, down from 40% last fall 📊
🔹 Republican support slides to 73%, lowest since start of second term 🗳️
🔹 365 consecutive days of negative net approval rating per CNN analysis 🗓️
🔹 Only 21% trust his ethics, 25% believe he respects democratic values ⚖️
🔹 Gas prices spike 19% to $3.45 due to Iran conflict hurting popularity ⛽
🔹 Independent voters abandoning Trump as war costs mount financially 💸
Is this the beginning of the end for Trump 2.0? The numbers don't lie 📈💥
#USNews#Trump#polls#approval
@america
First Combined Bitcoin-Ethereum ETFs Approved
✅ The SEC has approved the first combined spot ETFs for Bitcoin and Ethereum from Hashdex and Franklin Templeton. Asset allocation will be based on market capitalization, with Bloomberg analysts projecting a weight of approximately 80% Bitcoin and 20% Ethereum, reflecting current asset evaluations.
Read more
#SEC#ETF#Bitcoin#Ethereum#Hashdex#FranklinTempleton#Bloomberg#Crypto#Finance#Investment#Market#Assets#Approval#SpotETFs#Capitalization#Trading#AssetsAllocation#Investing#DigitalAssets#InvestmentStrategy