Skip to content

Instantly share code, notes, and snippets.

@HectorAE
Last active August 29, 2015 13:58
Show Gist options
  • Save HectorAE/9995888 to your computer and use it in GitHub Desktop.
Save HectorAE/9995888 to your computer and use it in GitHub Desktop.
Use stylish-haskell on many files at once.
#! /bin/sh
# Script that automatically runs stylish-haskell on the given file
# or every file in the given directory and its subdirectories.
# Written by Hector A Escobedo
if ! hash sponge 2> /dev/null
then
echo "The sponge dependency from moreutils is missing."
exit 1
fi
if ! hash stylish-haskell 2> /dev/null
then
echo "The stylish-haskell dependency is missing."
exit 1
fi
if [ -d "$1" ]
then
for f in `find $1 -type f`
do
stylish-haskell $f | sponge $f
done
elif [ -f "$1" ]
then
stylish-haskell $1 | sponge $1
else
echo "Usage: hs-stylize DIRECTORY/FILE"
exit 2
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment