呼应-e在终端下工作,但不是在bash脚本 [英] echo -e working in terminal but not in bash script
问题描述
我公司开发和维护称为Githug红宝石的宝石,我想纠正一个自动化测试脚本它。 Githug基本操作一个文件夹,把它变成一个工作Git仓库的不同状态,并可以执行Git命令解决的水平。
I developed and maintain a ruby gem called Githug and I am trying to right an automated test script for it. Githug basically manipulates a folder to put it into different states of a working git repository and you can execute git commands to "solve" the level.
一个水平的要求你的混帐配置细节,我做以下内容:
One of the levels asks you for your git config details and I am doing the following:
#! /bin/sh
# ...snip
#level 4
FULL_NAME=$(git config --get user.name)
EMAIL=$(git config --get user.email)
echo -e "$FULL_NAME\n$EMAIL" | githug
当我从一个bash脚本它(回声-e)不起作用执行。但它确实,当我从终端运行它。
When I execute from a bash script it (echo -e) doesn't work. But it does when I run it from the terminal.
FULL_NAME=$(git config --get user.name)
EMAIL=$(git config --get user.email)
echo -e "$FULL_NAME\n$EMAIL" | githug
********************************************************************************
* Githug *
********************************************************************************
What is your name? What is your email?
Congratulations, you have solved the level
为什么不这样从bash脚本工作?
Why doesn't this work from the bash script?
感谢。
推荐答案
错误的家当:
#! /bin/sh
当它应是一个bash脚本,用
When it shall be a bash script, use
#! /bin/bash
Bash有一个buildin的回声,这是不是100%,同文同/斌/回声。
Bash has a buildin echo, which isn't 100% identic with /bin/echo.
这篇关于呼应-e在终端下工作,但不是在bash脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!