replace stupid shell [[ operator with 'test' + fix bug in assigning variables in cmd to exec