任何人都可以告诉我,以下脚本有什么问题吗?
$
中的sed -i -e '\$a\\EXAM_CONFIG=\"OnlineExam.settings.$git_branch\"'
未逃避
echo """
#!/usr/bin/env bash
git --work-tree=/var/www/html/$dir_name --git-dir=/var/repo/$dir_name.git checkout -f $git_branch>/tmp/git_stdout>/tmp/git_stderr
source /var/www/html/$dir_name/$git_branch.sh
grep -q 'EXAM_CONFIG=\"OnlineExam.settings.$git_branch\"' /etc/environment && sed -i 's/EXAM_CONFIG=\"OnlineExam.settings.$git_branch\"/EXAM_CONFIG=\"OnlineExam.settings.$git_branch\"/g' /etc/environment || sed -i -e '\$a\\EXAM_CONFIG=\"OnlineExam.settings.$git_branch\"' /etc/environment
sudo pip install -r /var/www/html/$dir_name/requirements.txt
python /var/www/html/$dir_name/manage.py makemigrations
python /var/www/html/$dir_name/manage.py migrate
sudo service apache2 restart
""" > /var/repo/$dir_name.git/hooks/post-receive
我尝试使用'$a'
和\$a
但结果始终相同in this picture
每当我在终端中单独运行bash脚本时,我得到了所需的输出,如下所示