While trying to interact using the API I’ve just discovered that incus exec doesn’t run shell builtins. Trying to run the same command manually shows it can’t be execd outside the instance
incus exec trixie -- "! (test -e /root/yofile || test -L /root/yofile ) || ( stat -c 'user=%U group=%G mode=%A atime=%X mtime=%Y ctime=%Z size=%s %N' /root/yofile 2> /dev/null || stat -f 'user=%Su group=%Sg mode=%Sp atime=%a mtime=%m ctime=%c size=%z %N%SY' /root/yofile )"
Error: Command not found
but these same commands do work when run directly in an instance:
root@trixie:/# ! (test -e /root/yofile || test -L /root/yofile ) || ( stat -c 'user=%U group=%G mode=%A atime=%X mtime=%Y ctime=%Z size=%s %N' /root/yofile 2> /dev/null || stat -f 'user=%Su group=%Sg mode=%Sp atime=%a mtime=%m ctime=%c size=%z %N%SY' /root/yofile )
user=root group=root mode=-rw-r--r-- atime=1754357120 mtime=1754357120 ctime=1754357120 size=0 '/root/yofile'
Is there a flag/setting I’ve missed which instructs incus to also attempt shell builtins or do I need to wrap the tests up in some extra ‘shell -c’ magic to try and work around this? eg:
incus exec trixie -- /bin/bash -c "! (test -e /root/yofile || test -L /root/yofile ) || ( stat -c 'user=%U group=%G mode=%A atime=%X mtime=%Y ctime=%Z size=%s %N' /root/yofile 2> /dev/null || stat -f 'user=%Su group=%Sg mode=%Sp atime=%a mtime=%m ctime=%c size=%z %N%SY' /root/yofile )"
user=root group=root mode=-rw-r--r-- atime=1754357120 mtime=1754357120 ctime=1754357120 size=0 '/root/yofile'