Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
基于bash脚本中的读取条目设置git电子邮件_Bash_Git_Ansible - Fatal编程技术网

基于bash脚本中的读取条目设置git电子邮件

基于bash脚本中的读取条目设置git电子邮件,bash,git,ansible,Bash,Git,Ansible,我有一个ansible playbook调用多个.sh脚本,这一个失败了,因为它没有正确设置,这是我第一次使用read,但不知道如何正确使用它 #!/bin/bash echo "Please set your email address, stuff it up? enter git config user.email"; read ea; git config --global user.email $ea; exit; 我想让它做的是,因为目前它完全跳过了这个错误,或者只是跳过了错

我有一个ansible playbook调用多个.sh脚本,这一个失败了,因为它没有正确设置,这是我第一次使用read,但不知道如何正确使用它

#!/bin/bash
echo "Please set your email address, stuff it up? enter git config    user.email";
read ea;
git config --global user.email $ea;
exit;
我想让它做的是,因为目前它完全跳过了这个错误,或者只是跳过了错误,要求用户输入他们的电子邮件地址,并将git电子邮件设置为该输入,然后继续剧本的其余部分。 完成


而且,根据fine手册,他们可以通过运行ansible playbook和
--extra-vars'{“git_email”:“绕过提示”bob@example.com“}”

这在一定程度上有帮助,但当我需要执行命令来设置电子邮件git config--global user.email“email”时该变量没有设置或保存在任何地方以调用。这很好,但是“git_email”不存储提示输入的内容,并且在执行时不输出该条目。我在发布之前亲自执行了该代码段,包括有和没有
额外变量
位。请随时用您遇到的错误更新您的问题,我们将尝试解决它。它会很好地提示您,然后它会很清楚地打印到终端“git config--global user.email”{{{git_email}}”,当使用git config user.email检查时,会出现“{git_email}”变量提示:-名称:git\u电子邮件提示:请输入您的DJR电子邮件地址。private:无任务:-shell:| git config--global user.email“{{git_email}}”有人会注意到我说了“更新你的问题”,因为试图读取注释中的文本输出是痛苦的错误是我在提示出现时输入的值没有存储在任何地方,也没有存储在“git_email”中因此,当它实际运行该命令来设置它时,它实际上只有那些单词“git_email”
- hosts: localhost
  gather_facts: no
  become: no
  vars_prompt:
    - name: git_email
      prompt: Please enter your email address for use with git commits
      private: no
  tasks:
  - shell: |
      git config --global core.email "{{ git_email }}"