Bug 45145

Summary: Не корректная работа с переменными
Product: Sisyphus Reporter: alexunderboots <al.tar44046>
Component: shAssignee: 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 Flags
info none

Description alexunderboots 2023-02-07 04:23:50 MSK
update, dist, kernel

#!/bin/sh
export target1='up_exp_target'
target2='up_target'
su -c "export target3='down_exp_target'
target4='down_target'
echo $target1
echo $target2
echo $target3
echo $target4" root

$target3 и 4 внутри su - не существуют. А если su -c вызывает внешний файл, то всё норм
Comment 1 alexunderboots 2023-02-07 09:14:03 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
баг переместил на интерпретатор
Comment 2 Pavel Shilov 2023-03-23 16:42:28 MSK
Прошу предоставить дополнительную информацию
* uname -a
* cat /etc/os-release
* apt-repo
Comment 3 alexunderboots 2023-03-23 19:06:47 MSK
Created attachment 12790 [details]
info
Comment 4 Pavel Shilov 2023-03-27 12:28:02 MSK
Произвел тестирование на платформе, обновленной до 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-
Comment 5 alexunderboots 2023-04-03 06:44:33 MSK
Выполняю скрипт
#!/bin/sh
echo $pluscolor 'Настройка avachi' $nocolor
target=/etc/avahi
su -l -c "export avahidomain=$(hostname -s | cut -b 1-8)
        echo ${avahidomain}" root

В ответ получаю пустую строку
Comment 6 Dmitry V. Levin 2023-04-03 10:34:18 MSK
sh всё делает правильно, в строгом соответствии с документированной семантикой этих двух типов кавычек.
Comment 7 Dmitry V. Levin 2023-04-03 10:35:56 MSK
(In reply to Pavel Shilov from comment #2)
> Прошу предоставить дополнительную информацию
> * uname -a
> * cat /etc/os-release
> * apt-repo

Пожалуйста, такие сообщения надо закрывать, а не перевешивать.  Здесь занимаются ошибками, а не ликбезом.