Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- function rsync_rules () {
- rules=""
- while read path; do
- exclude=0
- if [ "${path:0:1}" == "!" ]; then
- exclude=1
- path=${path:1}
- fi
- if [[ "$path" == *..* ]]; then
- echo "Error: Invalid path $path, skipping"
- continue
- fi
- if [ ! -d "$(pwd)/$path" ]; then
- echo "Warning: File not found $path"
- fi
- if [ $exclude == 1 ]; then
- rules="$rules --exclude=\"$path\""
- else
- rules="$rules --include=\"$path\""
- fi
- done < $1
- }
- rsync_rules "$(pwd)/.rsync"
- echo $rules
- . ./test4.sh $rules
- ### output
- $ ./test3.sh
- Warning: File not found app/blabla
- --exclude="app/temp" --exclude="app/log" --include="app/temp/cache" --include="app/blabla" --include="app/fucking dir"
- test4 6 --exclude="app/temp" --exclude="app/log" --include="app/temp/cache" --include="app/blabla" --include="app/fucking dir"
Advertisement
Add Comment
Please, Sign In to add comment