Skip to content

Commit c84c00e

Browse files
committed
Fix some minor posix shell scripting issues
1 parent 7fc48bf commit c84c00e

File tree

3 files changed

+19
-19
lines changed

3 files changed

+19
-19
lines changed

test_config_syntax.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
set -eux
44

55
docker run --rm -it \
6-
--volume $(pwd)/postfix.grok:/etc/logstash/patterns.d/postfix.grok \
7-
--volume $(pwd)/50-filter-postfix.conf:/usr/share/logstash/pipeline/50-filter-postfix.conf \
6+
--volume "$(pwd)"/postfix.grok:/etc/logstash/patterns.d/postfix.grok \
7+
--volume "$(pwd)"/50-filter-postfix.conf:/usr/share/logstash/pipeline/50-filter-postfix.conf \
88
logstash:8.12.0 \
99
logstash --config.test_and_exit -f /usr/share/logstash/pipeline/50-filter-postfix.conf

test_grok_patterns.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ FROM ruby:slim
1212
RUN gem install jls-grok minitest
1313
EOF
1414

15-
docker run --volume $(pwd):"${VOLUMEPATH}" --workdir ${VOLUMEPATH} ${DOCKERIMAGE} sh -c "ruby test/test.rb"
15+
docker run --volume "$(pwd)":"${VOLUMEPATH}" --workdir ${VOLUMEPATH} ${DOCKERIMAGE} sh -c "ruby test/test.rb"

test_pipeline.sh

+16-16
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ OUTPUT=$(mktemp tmp.logstash.out.XXXXX)
77
PIPELINE=$(mktemp tmp.logstash.pipeline.XXXXX)
88

99
echo Preparing input data
10-
echo "postfix/smtp[123]: 7EE668039: to=<[email protected]>, relay=127.0.0.1[127.0.0.1]:2525, delay=3.6, delays=0.2/0.02/0.04/3.3, dsn=2.0.0, status=sent (250 2.0.0 Ok: queued as 153053D)" > $INPUT
10+
echo "postfix/smtp[123]: 7EE668039: to=<[email protected]>, relay=127.0.0.1[127.0.0.1]:2525, delay=3.6, delays=0.2/0.02/0.04/3.3, dsn=2.0.0, status=sent (250 2.0.0 Ok: queued as 153053D)" > "$INPUT"
1111

1212
echo Preparing pipeline config
13-
cat > $PIPELINE << EOF
13+
cat > "$PIPELINE" << EOF
1414
input {
1515
file {
1616
path => "/tmp/logstash.in"
@@ -26,9 +26,9 @@ filter {
2626
}
2727
EOF
2828

29-
cat 50-filter-postfix.conf >> $PIPELINE
29+
cat 50-filter-postfix.conf >> "$PIPELINE"
3030

31-
cat >> $PIPELINE << EOF
31+
cat >> "$PIPELINE" << EOF
3232
output {
3333
file {
3434
path => "/tmp/logstash.out"
@@ -38,32 +38,32 @@ EOF
3838

3939
echo Starting logstash docker container
4040
CONTAINER_ID=$(docker run --rm --detach \
41-
--volume ./${INPUT}:/tmp/logstash.in \
42-
--volume ./${OUTPUT}:/tmp/logstash.out \
41+
--volume ./"${INPUT}":/tmp/logstash.in \
42+
--volume ./"${OUTPUT}":/tmp/logstash.out \
4343
--volume ./postfix.grok:/etc/logstash/patterns.d/postfix.grok \
44-
--volume ./${PIPELINE}:/usr/share/logstash/pipeline/pipeline.conf \
44+
--volume ./"${PIPELINE}":/usr/share/logstash/pipeline/pipeline.conf \
4545
logstash:8.12.0 \
4646
logstash -f /usr/share/logstash/pipeline/pipeline.conf)
4747

48-
echo -n "Waiting for output from logstash "
49-
until test -s $OUTPUT; do
50-
echo -n "."
48+
printf "Waiting for output from logstash "
49+
until test -s "$OUTPUT"; do
50+
printf "."
5151
sleep 2
5252
done
5353
echo
5454

55-
docker stop --time 1 $CONTAINER_ID > /dev/null
55+
docker stop --time 1 "$CONTAINER_ID" > /dev/null
5656

57-
if test "$(jq .tags[0] $OUTPUT)" = '"_grok_postfix_success"'; then
57+
if test "$(jq .tags[0] "$OUTPUT")" = '"_grok_postfix_success"'; then
5858
echo Grok processing successful!
59-
jq . $OUTPUT
59+
jq . "$OUTPUT"
6060
else
6161
echo "Grok processing failed :<"
62-
jq . $OUTPUT
62+
jq . "$OUTPUT"
6363
exit 1
6464
fi
6565

6666
echo Cleaning up
67-
rm -f $INPUT $OUTPUT $PIPELINE
67+
rm -f "$INPUT" "$OUTPUT" "$PIPELINE"
6868

69-
echo Done
69+
echo Done

0 commit comments

Comments
 (0)