/bin/bash Proper Whitespace Handling - Whitespace Safety
< Dev
Jump to navigation
Jump to search

Your support makes
all the difference!
We believe security software like Kicksecure needs to remain open source and independent. Would you help sustain and grow the project? Learn more about our 10 year success story and maybe DONATE!
Supporting multiple command line parameters with spaces in wrapper scripts.
Bash Proper Whitespace Handling[edit]
#!/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[@]}"
misc[edit]
base_name="${file_name##*/}" file_extension="${base_name##*.}"
Unfinished: This wiki is a work in progress. Please do not report broken links until this notice is removed, use Search Engines First and contribute improving this wiki.