Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#! /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
You can’t perform that action at this time.