Say I want to write wrapper for `chroot` command with the possibility to set working directory otherwise preserving `chroot` semantics. Thus semantics should be:

```
chroot.sh <chroot-dir> <working-dir> <command> [arg]...

```

My naive attempt is:

```
#!/bin/sh

chroot_dir=$1
working_dir=$2

shift 2

chroot "$chroot_dir" sh -c "cd $working_dir; $*"

```

But this fails to correctly handle:

```
chroot.sh /path/to/chroot /tmp touch 'filename with space'

```

I cannot figure out how it should be implemented correctly.
Is it possible using bash only?

On my CentOS 6 system `chroot` command doesn't support setting working directory. Probably this is not true on other systems.