+ handling input arguments with spaces

This commit is contained in:
committer
2024-06-11 06:59:01 -05:00
parent 94bb5850aa
commit d02fc00606

View File

@@ -8,7 +8,6 @@ if [ $# -lt 1 ]; then
echo "usage: '$this_file_name [path_to_file]'"
exit 1
fi
input_files=( "$@" )
sync_dir_sym=/home/${USER}/syncDir
syncdir_env_var=SYNCDIR_${HOSTNAME}
@@ -16,15 +15,17 @@ sync_dir=${!syncdir_env_var} # '!' to use the name and not the value
cwd=$(pwd)
# nifty for debugging:
echo "debugging values:"
echo ${input_files[@]}
echo ${sync_dir_sym}
echo ${sync_dir}
echo ${cwd}
echo
#echo
#echo "debugging values:"
#echo "input args: $@"
#for i in "$@"; do echo " $i"; done;
#echo "sync_dir_sym: ${sync_dir_sym}"
#echo "sync_dir: ${sync_dir}"
#echo "cwd: ${cwd}"
#echo
# loop through all files to delete
for input_file in ${input_files[@]}; do
for input_file in "$@"; do
# if input file has not path specified
if [[ ${input_file} != *"/"* ]]; then
@@ -43,7 +44,8 @@ for input_file in ${input_files[@]}; do
new_file=${input_file//$sync_dir_sym/$sync_dir}
if [[ -f "${new_file}" ]] || [[ -d "${new_file}" ]] ; then
trash-put "${new_file}"
#trash-put "${new_file}"
echo "${new_file}"
else
echo "error: unable to delete '${new_file}'"
fi