[windows] skip 'UNIX only'
[!umask:022] skip

# test that scripts in subdirectories are run in the subdirectory
chezmoi apply --force
cmpenv stdout golden/apply

chezmoi dump
cmp stdout golden/dump.json

chezmoi archive --gzip --output=archive.tar.gz
exec tar -tzf archive.tar.gz
[!openbsd] cmp stdout golden/archive
[openbsd] cmp stdout golden/archive-openbsd

-- golden/apply --
$HOME
$HOME/dir
$HOME/anotherdir
-- golden/archive --
otherdir/script.sh
anotherdir/
dir/
dir/script.sh
otherdir/
anotherdir/script.sh
-- golden/archive-openbsd --
otherdir/script.sh
anotherdir
dir
dir/script.sh
otherdir
anotherdir/script.sh
-- golden/dump.json --
{
  "anotherdir": {
    "type": "dir",
    "name": "anotherdir",
    "perm": 493
  },
  "anotherdir/script.sh": {
    "type": "script",
    "name": "anotherdir/script.sh",
    "contents": "#!/bin/sh\n\npwd\n"
  },
  "dir": {
    "type": "dir",
    "name": "dir",
    "perm": 493
  },
  "dir/script.sh": {
    "type": "script",
    "name": "dir/script.sh",
    "contents": "#!/bin/sh\n\npwd\n"
  },
  "otherdir": {
    "type": "dir",
    "name": "otherdir",
    "perm": 493
  },
  "otherdir/script.sh": {
    "type": "script",
    "name": "otherdir/script.sh",
    "contents": "#!/bin/sh\n\npwd\n"
  }
}
-- home/user/.local/share/chezmoi/anotherdir/run_after_script.sh --
#!/bin/sh

pwd
-- home/user/.local/share/chezmoi/dir/run_script.sh --
#!/bin/sh

pwd
-- home/user/.local/share/chezmoi/otherdir/run_before_script.sh --
#!/bin/sh

pwd
