Skip to content

Commit 041b2ab

Browse files
committed
Use sed instead of envsubst for more portability
1 parent 8bf27c1 commit 041b2ab

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

webapp/src/main/resources/templates/cli/install.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,12 @@
1919
mkdir -p {{installDirectory}}
2020

2121
# Create the bash wrapper for the CLI
22-
cat << 'EOF' | envsubst '$PWD' > {{installDirectory}}/mojito
22+
cat > {{installDirectory}}/mojito-tmp << 'EOF'
2323
#!/usr/bin/env bash
2424
{{#hasHeaders}}
2525
{{#headers}}
2626
if [ -z "{{{envVarPresenceCheck}}}" ]; then
2727
echo "Environment variable {{envVar}} must be set before running this command."
28-
exit 1
2928
fi
3029
{{/headers}}
3130
{{#authenticationMode}}
@@ -39,6 +38,10 @@ java -Dl10n.resttemplate.host={{host}} \
3938
-jar {{installDirectory}}/mojito-cli.jar "$@" ;
4039
EOF
4140

41+
_ESC="$(printf '%s' "${PWD}" | sed 's/[\/&]/\\&/g')"
42+
sed "s|\${PWD}|$_ESC|g" {{installDirectory}}/mojito-tmp > {{installDirectory}}/mojito
43+
rm {{installDirectory}}/mojito-tmp
44+
4245
# Make the wrapper executable
4346
chmod +x {{installDirectory}}/mojito
4447

0 commit comments

Comments
 (0)