Skip to content

launching retry into the background disrupts bash's while read -r #20

@adrelanos

Description

@adrelanos

test script:

#!/bin/bash

set -x
set -e

command -v retry >/dev/null

testfile=./testfile
echo "1
2
3" > "$testfile"

while read -r testvar ; do
  true "testvar: $testvar"

  retry --times=3 --delay=1 -- /bin/true &
  pid=$!

  wait "$pid"
  true "WAIT OK"
done < "$testfile"

true "END"

chmod +x ./test

./test

actual output:

+ set -e
+ command -v retry
+ testfile=./testfile
+ echo '1
2
3'
+ read -r testvar
+ true 'testvar: 1'
+ pid=395200
+ wait 395200
+ retry --times=3 --delay=1 -- /bin/true
+ true 'WAIT OK'
+ read -r testvar
+ true END

The loop runs actually only 1 time instead of the expected 3 times.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions