git - Zip with ignore within Bash script -


found wonderful little bash script i've adapted use zip compressing managed directories, ignoring files bower_components, .git , node_modules:

#!/bin/bash # script zips directory, excluding specified files, types , subdirectories. #  while zipping directory excludes hidden directories , file types  [[ "`/usr/bin/tty`" == "not tty" ]] && . ~/.bash_profile  directory=$(cd `dirname $0` && pwd)  if [[ -z $1 ]];   echo "usage: managed_directory_compressor /your-directory/ zip-file-name" else   directory_to_compress=$1   zipped_file="$2.zip"   compress_ignore_dir=("\.git" "node_modules" "bower_components")    ignore_list=("*/\.*" "\.* "\/\.*"")   if [[ -n $compress_ignore_dir ]];       ignore_dir in "${compress_ignore_dir[@]}";           ignore_list+=("$directory_to_compress/$ignore_dir/***")  ## "$directory_to_compress/$ignore_dir/*"  perhaps enough?       done   fi    zip -r "$zipped_file" "$directory_to_compress" -x "${ignore_list[@]}" # >/dev/null   echo zip -r "$zipped_file" "$directory_to_compress" -x "${ignore_list[@]}" # >/dev/null   echo "done" fi 

the problem directories want ignore still being created, empty.

any suggestions?

the zip-man-page says

note trailing / needed directories (as in

zip -r foo . -i dir/ 

to include directory dir).

so, likewise exclusion seems work: replacing marked line in script by

ignore_list+=("$directory_to_compress/$ignore_dir/") 

should trick.

(my zip version 3.0 on ubuntu-linux)


Comments

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -