TGTGInsighttelegram intelligenceLIVE / telegram public index
← Python Заметки

TGINSIGHT SIMILAR POSTS

Најди сличен содржај

Изворен канал @pythonotes · Post #411 · 9 фев.

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

Резултати

Пронајдени 1 слични објави

Пребарај: #juba

当前筛选 #juba清除筛选
Addis Standard

@addisstandardeng · Post #21074 · 14.01.2026 г., 15:55

News: #Ethiopia’s Foreign Affairs and Water Ministers visit #Juba amid intensified regional diplomacy Days after Prime Minister Abiy Ahmed’s visit to #Djibouti and the unannounced trip of Ethiopia’s intelligence chief to #Mogadishu, Ethiopia’s Minister of Foreign Affairs, Gedion Timothewos (Phd), accompanied by Minister of Water and Energy Habtamu Itefa Geleta (Phd) and senior officials, arrived in Juba for high-level talks with South Sudanese counterparts on regional stability and bilateral cooperation. According to statements from the foreign ministries of both countries, the Ethiopian delegation met on 13 January 2026 with Ambassador Monday Semaya K. Kumba, South Sudan’s Minister of Foreign Affairs and International Cooperation. The meeting was also attended by James Mawich Makuach, Minister of Water Resources and Irrigation, alongside senior officials from both sides..... https://web.facebook.com/AddisstandardEng/posts/pfbid0J1kw3U5SWvJ5UbwVqVQJUEyuiNVpFoyiGjAYoDhRjXDE8mQvxGyHEV62mRzpSys5l