Skip to content

Instantly share code, notes, and snippets.

@yangsheng1107
Created December 25, 2015 05:48
Show Gist options
  • Select an option

  • Save yangsheng1107/f44ee23deeb55a0ea78d to your computer and use it in GitHub Desktop.

Select an option

Save yangsheng1107/f44ee23deeb55a0ea78d to your computer and use it in GitHub Desktop.
#!/bin/bash
function loop() {
## Do nothing if * doesn't match anything.
## This is needed for empty directories, otherwise
## "foo/*" expands to the literal string "foo/*"/
shopt -s nullglob
## Make ** recurse into subdirectories
shopt -s globstar
for file in "$@"/**
do
## If $file is a *.c file
if [[ $file == *.c ]]
then
#echo "$file"
uncrustify -c ~/uncrustify.cfg -l c --replace --no-backup $file
fi
## If $file is a *.h file
if [[ $file == *.h ]]
then
#echo "$file"
uncrustify -c ~/uncrustify.cfg -l c --replace --no-backup $file
fi
done
}
loop "$PWD"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment