Improved escapeShellArg function