Sanitize user input in bash for security purposes
问题 How do I sanitise user input in a bash script so that I can then pass it as an argument to another shell program? I want to prevent the following: INPUT="filename;rm -rf /" ls $INPUT I was thinking it should be enough to surround the user input in double quotes like so: ls "$INPUT" but what if there is a double quote in $INPUT ? Or does bash already deal with this problem? 回答1: The Short Bash already deals with that. Quoting it is sufficient. ls "$INPUT" The Long A rough guide to how the