Normally, when a bash variable is passed, the value gets written in a file, but when the variable has a value obtained from git command, the value does not get written in the output html file. Here is my snippet:
#!/bin/bash
echo "Obtaining Revision Number"
cd /path/to/project/
revision_number= git rev-parse --short HEAD
cat > /path/to/myFile/file.html << EOF
The revision number is "${revision_number}"
EOF
Output: The revision number is
Please note that when I use the command in the script using the revision_number it works
git show -s --format=%B $revision_number
Also, if I use static declaration the value gets passed in the html file
#!/bin/bash
echo "Obtaining Revision Number"
cd /path/to/project/
firstName=John
cat > /path/to/myFile/file.html << EOF
The revision number is "${firstName}"
EOF
Outout: The revision number is John
CodePudding user response:
You need to get the value like this:
revision_number=$(git rev-parse --short HEAD)