I developed and maintain a ruby gem called Githug and I am trying to write an automated test script for it. Githug basically manipulates a directory 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
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
Why doesn't this work from the bash script?
Thanks.
The echo command is one of the most commonly and widely used built-in commands for Linux bash and C shells, that typically used in a scripting language and batch files to display a line of text/string on standard output or a file. 2.
The echo command writes text to standard output (stdout). The syntax of using the echo command is pretty straightforward: echo [OPTIONS] STRING... Some common usages of the echo command are piping shell variable to other commands, writing text to stdout in a shell script, and redirecting text to a file.
Usually, you get the error bash permission denied when running some script/file that does not have execute permissions. All you need to do is to change file permissions and add executive one.
Wrong shebang:
#! /bin/sh
When it shall be a bash script, use
#! /bin/bash
Bash has a buildin echo, which isn't 100% identic with /bin/echo.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With