[windows] skip 'atomic writes aren''t supported on Windows'
[!exec:sh] skip 'sh is required to run this test'

# If we don't do atomic writes, most shells will error when shfmt overwrites the
# very script it's running from. This is because the shell doesn't read all of
# the input script upfront.
exec sh input.sh
cmp stdout stdout.golden
! stderr .

cmp input.sh input.sh.golden

-- input.sh --
echo foo
  shfmt -l -w input.sh
echo bar
-- input.sh.golden --
echo foo
shfmt -l -w input.sh
echo bar
-- stdout.golden --
foo
input.sh
bar
