(I also have this problem with Samba 3)
~$ smbclient -U user%pass \\\\server\\outbox -c "rmdir [PROTECTED-FOLDER]"
> NT_STATUS_UNSUCCESSFUL removing remote directory file \[PROTECTED-FOLDER]
~$ echo $?
As this is an error, smbclient should return 1.
Please note that smbclient already returns 1, for example when it fails to rename the very same folder.
If you want a proper patch, I can provide it.
Otherwise, you just need to add a "return 1;" after this line:
You may also want to check all return codes in the same file. For example, there is apparently the same problem when trying to delete files:
This fix may not be just cosmetic. For example, return codes are useful when writing tests.