Skip to content

Conversation

@mreiden
Copy link
Contributor

@mreiden mreiden commented Jun 13, 2019

Remove trailing whitespace in txt, xml, and php files. Remove closing php tags in php class files.

@mreiden
Copy link
Contributor Author

mreiden commented Jun 14, 2019

The whitespace changes were done with these commands on RHEL7 (sed's -c preserves file permissions and ownership).

export LC_CTYPE=C
export LANG=C

# Remove trailing whitespace
find . -not \( -name .svn -prune -o -name .git -prune \) \( -iname "*.php" -o -iname "*.txt" -o -iname "*.xml" \) -type f -print0 | xargs -0 sed -c -i -E "s/[[:space:]]*$//"

# Combine multiple trailing newlines at EOF
find . -not \( -name .svn -prune -o -name .git -prune \) \( -iname "*.php" -o -iname "*.txt" -o -iname "*.xml" \) -type f -print0 | xargs -0 sed -c -i -e :a -e '/^\n*$/{$d;N;};/\n$/ba'

# Add a trailing newline if there is not one
find . -not \( -name .svn -prune -o -name .git -prune \) \( -iname "*.php" -o -iname "*.txt" -o -iname "*.xml" \) -type f -print0 | xargs -0 sed -c -i -e '$a\'

The php ending tags were removed after that manually (which explains why a few files were missed).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant