I have the following function in a shell script meant to handle some basic grep checks for a server setting in ~/.m2/settings.xml:
SETTINGS_FILE="~/.m2/settings.xml"
SETTINGS_SERVER_ID="<id>ossrh</id>"
check_settings () {
echo grep "$1" "$SETTINGS_FILE"
if grep -q "$1" "$SETTINGS_FILE"; then
echo "Server is set up...\n"; else
echo "DEPLOY FAILED:\n\t$1 not found in ${SETTINGS_FILE}!
fail "Fail :(";
fi
return 0
}
check_settings $SETTINGS_SERVER_ID
Unfortunately, this results in the following message:
grep <id>ossrh</id> ~/.m2/settings.xml
grep: ~/.m2/settings.xml: No such file or directory
DEPLOY FAILED:
<id>ossrh</id> not found in ~/.m2/settings.xml!
Fail :(
Meanwhile, just using grep "<id>ossrh</id>" ~/.m2/settings.xml
in the bash returns <id>ossrh</id>
, which is expected.
I'm wondering if this is an issue of visibility- whether grep can see things in hidden directories (unlikely, considering this question) or whether it is an issue with the argument I'm passing grep (likely, considering how new I am to shell scripting)