bash - Filter out directories using Makefile list -


i'm trying make release rule makefile it's job copy directories in folder, except few (like destination etc) have looked @ makefile filter function seems it's not working inside of bash loop? there easy way filter out items in list in bash?

source_dir=builds/$(name)_$(version)  #list of items ignore ignore=builds cfg compiled  release: if [ -d "cfg" ]; \     cp -r cfg $(source_dir)/cfg; \ fi; folder in *; \     if [ -d "$$folder" ]; \             if [[ $(ignore) != $$folder ]]; \                 cp -r $$folder $(source_dir)/addons/; \             fi; \     fi; \ done; 

the filter-out function make function, if want use it, must use before pass command shell.

you can use outside rule:

things := $(wildcard *) ignore = builds cfg compiled things := $(filter-out $(ignore), $(things))  release:     @for folder in $(things); \       if [ -d $$folder ]; \         echo $$folder; \       fi; \      done 

or inside rule:

things := $(wildcard *) ignore = builds cfg compiled  release:     @for folder in $(filter-out $(ignore), $(things)); \       if [ -d $$folder ]; \         echo $$folder; \       fi; \      done 

or stick for folder in *... , filter list in bash:

ignore = builds cfg compiled  release:     @for folder in *; \       if [ -d $$folder ]; \         [[ "$(ignore)" =~ $$folder ]] || echo $$folder; \       fi; \      done 

Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -