{{Header}} {{title|title= /bin/bash Proper Whitespace Handling - Whitespace Safety }} {{#seo: |description=Supporting multiple command line parameters with spaces in wrapper scripts. }} {{intro| Supporting multiple command line parameters with spaces in wrapper scripts. }} = Bash Proper Whitespace Handling =
#!/bin/bash ## https://yakking.branchable.com/posts/whitespace-safety/ set -e app_user=user lib_dir="/tmp/test/lib/program with space/something spacy" main_app_dir="/tmp/test/home/user/folder with space/abc" mkdir -p "$lib_dir" mkdir -p "$main_app_dir" declare -a cmd cmd+=("cp") cmd+=("-r") cmd+=("${lib_dir}") cmd+=("${main_app_dir}/") "${cmd[@]}"= nounset - Check if Variable Exists =
#!/bin/bash set -x set -e set -o nounset ## Enable for testing. #unset HOME if [ -z "${HOME+x}" ]; then echo "Error: HOME is not set." fi echo "$HOME"= misc =
base_name="${file_name##*/}" file_extension="${base_name##*.}"{{Footer}} [[Category: Design]]