Skip to content

Instantly share code, notes, and snippets.

@henriquemoody
Created August 23, 2011 13:57
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save henriquemoody/1165190 to your computer and use it in GitHub Desktop.
Save henriquemoody/1165190 to your computer and use it in GitHub Desktop.
Remove PHP short tags
#! /bin/sh
ignore='\.svn';
for file in $(egrep '<\?$' -Rn --include=*.php . | egrep -v "${ignore}" | cut -d':' -f1 | sort | uniq);
do
sed -ri 's/<\?$/<?php/g' ${file};
done;
for file in $(egrep '<\?([^px=])' -Rn --include=*.php . | egrep -v "${ignore}" | cut -d':' -f1 | sort | uniq);
do
sed -ri 's/<\?([^px=])/<?php \1/g' ${file};
done;
for file in $(egrep '<\?=' -Rn --include=*.php . | egrep -v "${ignore}" | cut -d':' -f1 | sort | uniq);
do
sed -ri 's/<\?=/<?php echo /g' ${file};
done;
for file in $(egrep '<\?php[^\s\n\r]' -Rn --include=*.php . | egrep -v "${ignore}" | cut -d':' -f1 | sort | uniq);
do
sed -ri 's/<\?php([^\s\n\r])/<?php \1/g' ${file};
done;
for file in $(egrep '<\?php +' -Rn --include=*.php . | egrep -v "${ignore}" | cut -d':' -f1 | sort | uniq);
do
sed -ri 's/<\?php\s+/<?php /g' ${file};
done;
for file in $(egrep '\?>' -Rn --include=*.php . | egrep -v "${ignore}" | cut -d':' -f1 | sort | uniq);
do
sed -ri 's/([^\n\r\s]+)\?>/\1 ?>/g' ${file};
sed -ri 's/\s+\?>/ ?>/g' ${file};
done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment