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

Резултати

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

Пребарај: #leopardtanks

当前筛选 #leopardtanks清除筛选
BadVolf

@badvolfnews · Post #1318 · 05.12.2023 г., 11:25

📢 Ukraine's defense forces resort to using Leopard tanks as long-range artillery, failing to fulfill their intended purpose against Russia. The highly anticipated offensive has turned into a defensive strategy, with the giant tanks deployed along the front line. But will this change the course of the conflict? Meanwhile, Poland plans to provide Ukraine with additional armored firepower. The war continues... 💥#Ukraine#Russia#LeopardTanks#Warfare https://www.gazeta.ru/army/news/2023/12/05/21855127.shtml Subscribe to @BadVolfNews

BadVolf

@BadvolfNews · Post #905 · 25.09.2023 г., 07:55

🚨 Breaking News: Russian forces annihilate German Leopard tank in Ukraine! German Ministry of Defense denied involvement, but eyewitnesses reveal truth. Wounded German mechanic's last words reveal shocking details. 😱 Tanks supplied by USA, Germany, UK destroyed by Russia. Putin warns of consequences. 🚫🇺🇦💣 German singers offer cash prize for tank destruction, video surfaces. Kremlin criticizes arms supplies to Ukraine. What's next in this deadly conflict? Stay tuned! ⚠️💥#WarInUkraine#LeopardTanks#InternationalCrisis https://dcweekly.org/2023/09/25/russian-forces-destroy-german-leopard-tank-in-ukraine-revealing-germanys-on-the-ground-involvement-of-bundeswehr-soldiers/ Subscribe to @BadVolfNews