This commit is contained in:
2025-12-19 11:40:54 +03:00
parent 9c8d3a7b5f
commit e9f6af1b55
20 changed files with 76 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 89 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 365 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 541 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 848 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 438 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 605 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 664 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 784 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 145 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 251 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 129 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 172 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

14
unix/25-1/5/README.md Normal file
View File

@ -0,0 +1,14 @@
Вариант 109
Написать 2 shell-процедуры
Первая процедура:
при первом получении сигнала <ctrl+c> выдает на терминал сообщение «Доброе
утро»;
при втором получении сигнала <ctrl+c> выдает на терминал сообщение «Добрый
день»;
при третьем получении сигнала <ctrl+c> выдает на терминал сообщение «Добрый
вечер»;
при получении сигнала <ctrl+\> запускает n раз (n передается в процедуру в качестве
параметра) в фоновом режиме процедуру 2 и на этом завершает свою работу.
Вторая процедура:
создает в текущем каталоге подкаталог С, делает его текущим и на этом завершает
свою работу.

62
unix/25-1/5/main.sh Executable file
View File

@ -0,0 +1,62 @@
#!/bin/env bash
set -exu
if [ "$#" -ne 1 ]; then
echo "Неверное число аргументов" >&2
exit 1
fi
COUNT=0
N=$1
int_handler() {
case $COUNT in
0)
echo "Доброе утро"
;;
1)
echo "Добрый день"
;;
2)
echo "Добрый вечер"
;;
esac
COUNT=$(((COUNT + 1) % 3))
return 0
}
chdir() {
mkdir -p "C"
if [ ! -d "C" ]; then
echo "Не удалось создать каталог ${PWD}/C" >&2
return 1
fi
cd "C" || {
echo "Не удалось перейти в каталог ${PWD}/C" >&2
return 1
}
return 0
}
quit_handler() {
for ((i=0; i<$N; i++)) do
chdir
if [ "$?" -ne 0 ]; then
echo "Обработка сигнала QUIT не удалась"
return 1
fi
done
exit 1
}
trap int_handler INT
trap quit_handler QUIT
while true; do
read -t 1 || true
done