Skip to content

Instantly share code, notes, and snippets.

@mvidner
Created October 5, 2011 08:55
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 mvidner/1263970 to your computer and use it in GitHub Desktop.
Save mvidner/1263970 to your computer and use it in GitHub Desktop.
#! /bin/sh
# Convert ancient YCP syntax:
# define TYPE NAME(ARGS) ``{ BODY }
# becomes
# TYPE NAME(ARGS) { BODY }
#
# usage: $0 foo.ycp
# or
# cd tree_to_find_ycp_in; $0
FINDARGS="-name *.ycp"
S='[[:space:]]*'
SEDSCRIPT='s/\('$S'\)define'$S'\([^`]*\)\(``\)\?{/\1\2{/'
# the rest of the script is generic
if [ -z "$1" ]; then
find . $FINDARGS | xargs --max-args=1 $0
else
sed -i.bak -e "$SEDSCRIPT" "$1"
if cmp -s "$1.bak" "$1"; then
mv "$1.bak" "$1"
else
echo "$1"
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment