Are you using the helper in both scripts ?
MacroDroid alone is not able to interact with storage unless given permission (when you select a file/folder) but it seems the helper can through shell scripts.
I'm afraid I can't say anything else than the way both command work is different (and requires different permissions ?). I'm not that good at shell script as I don't use them often.
Just now I updated MD.... and now it seems both commands works!
and concerning local variable is empty
i will continue testing other script commands...