Skip to content

Instantly share code, notes, and snippets.

@corytodd
Created April 3, 2016 21:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save corytodd/2c945c7b67ab08aae139f90dfdae3619 to your computer and use it in GitHub Desktop.
Save corytodd/2c945c7b67ab08aae139f90dfdae3619 to your computer and use it in GitHub Desktop.
#!/bin/sh
# Makefile fixer
# Some old projects that have been touched by dumb text editors
# may have had their makefile tabs turned in spaces. For large
# projects, this is a pia to fix. Use this script in your project
# directory as a quick fix. +1 for the expand command.
set -e
old="$1"
new="$2"
echo "Replacing leading Makefile spaces with 1 hard tab ..."
count=0
for file in $(find . -name 'Makefile'); do
if [ -f $file ] && [ -w $file ]; then
echo "Fixing $file"
unexpand --first-only "$file"
count=$((count+1))
fi
done
echo "Updated $count files"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment