Skip to content

Commit

Permalink
MacOS/BSD Use gnu indent (#2267)
Browse files Browse the repository at this point in the history
The `indent` program used by Grass is not the original BSD one.

On FreeBSD (and other BSD and maybe MacOs) we have to use `gindent` which is the gnu indent.
  • Loading branch information
lbartoletti committed Aug 29, 2022
1 parent 4ca037f commit f648b9c
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion utils/grass_indent.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,25 @@

# TODO: replace short flags by long ones to improve readability

case "$(uname)" in
Darwin | *BSD*)
INDENT=$(which gindent)
;;
*)
INDENT=$(which indent)
;;
esac

if [ -z "$INDENT" ]; then
echo "Failed to find the 'indent' (or 'gindent' on BSD platforms) command."
exit 1
fi

if [ $# -lt 1 ] ; then
echo "No files specified (give file name(s) as parameter)"
exit 1
else
indent -npro -bad -bap -bbb -br -bli0 -bls -cli0 -ncs -fc1 -hnl -i4 \
${INDENT} -npro -bad -bap -bbb -br -bli0 -bls -cli0 -ncs -fc1 -hnl -i4 \
-nbbo -nbc -nbfda -nbfde -ncdb -ncdw -nce -nfca -npcs -nprs \
-npsl -nsc -nsob -saf -sai -saw -sbi0 -ss --no-tabs "$@"

Expand Down

0 comments on commit f648b9c

Please sign in to comment.