Summary: | Не корректная работа с переменными | ||||||
---|---|---|---|---|---|---|---|
Product: | Sisyphus | Reporter: | alexunderboots <al.tar44046> | ||||
Component: | sh | Assignee: | Dmitry V. Levin <ldv> | ||||
Status: | CLOSED NOTABUG | QA Contact: | qa-sisyphus | ||||
Severity: | critical | ||||||
Priority: | P5 | CC: | al.tar44046, glebfm, ldv, placeholder, shilovps | ||||
Version: | unstable | ||||||
Hardware: | all | ||||||
OS: | Linux | ||||||
Attachments: |
|
Description
alexunderboots
2023-02-07 04:23:50 MSK
Меняем кавычки #!/bin/sh export target1='up_exp_target' target2='up_target' su -c 'export target3="down_exp_target" target4="down_target" who echo $target1 echo $target2 echo $target3 echo $target4' root и вуаля - 1,3 и 4 видятся внутри su баг переместил на интерпретатор Прошу предоставить дополнительную информацию * uname -a * cat /etc/os-release * apt-repo Created attachment 12790 [details]
info
Произвел тестирование на платформе, обновленной до Sisyphus: * p10-workstation-10.1-x86-64 Версия пакета: * sh-4.4.23-alt1 Шаги воспроизведения: 1. создать файл скрипта проверки: $ vim test.sh с текстом #!/bin/sh export target1='up_exp_target' target2='up_target' su -c "export target3='down_exp_target' target4='down_target' who echo $target1 echo $target2 echo $target3 echo $target4 who" root 2. Запустить скрипт: $ bash test.sh 3. Создать другой файл с другими кавычками: $ vim test1.sh с текстом !/bin/sh export target1='up_exp_target' target2='up_target' su -c 'export target3="down_exp_target" target4="down_target" who echo $target1 echo $target2 echo $target3 echo $target4' root Фактический результат: Вывод в терминал test1.sh up_exp_target down_exp_target down_target Ожидаемый результат: Вывод в терминал test1.sh up_exp_target target3 и target4 выводятся от пользователя su- Выполняю скрипт #!/bin/sh echo $pluscolor 'Настройка avachi' $nocolor target=/etc/avahi su -l -c "export avahidomain=$(hostname -s | cut -b 1-8) echo ${avahidomain}" root В ответ получаю пустую строку sh всё делает правильно, в строгом соответствии с документированной семантикой этих двух типов кавычек. (In reply to Pavel Shilov from comment #2) > Прошу предоставить дополнительную информацию > * uname -a > * cat /etc/os-release > * apt-repo Пожалуйста, такие сообщения надо закрывать, а не перевешивать. Здесь занимаются ошибками, а не ликбезом. |