Skip to content

Commit

Permalink
Clean up clean-up scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
ksandom committed Aug 18, 2022
1 parent 2dc4761 commit 007937f
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
29 changes: 29 additions & 0 deletions utils/deprecated/stripNonEssentialConfig.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash
# Strip out non essential entries from a config file.
# This is used to help you focus when deriving a new gestureLayout from and old one. It also makes sure that what you set gets loaded in the way that you expect.
# The entries that are stripped out are everything that is not "value".
#
# Syntax:
# $0 "fileName.yml"

function showHelp
{
echo >&2
grep -B1000 '^function showHelp$' "$0" | grep '^# ' | sed 's/^# //g;s#\$0#'"$0"'#g' >&2
exit 1
}

if [ "$1" == "" ]; then
echo "You need to specify a filename." >&2
showHelp
elif [ ! -e "$1" ]; then
echo "The file \"$1\" doesn't appear to exist." >&2
showHelp
fi

fileName="$1"
temporaryFileName="$fileName.cleaned"

grep '\(:$\|^ *\(value: \|groups\)\)' "$fileName" > "$temporaryFileName"
diff "$temporaryFileName" "$fileName"
mv "$temporaryFileName" "$fileName"
4 changes: 2 additions & 2 deletions utils/stripNonEssentialConfig.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# Strip out non essential entries from a config file.
# Strip out a few non essential entries from a config file.
# This is used to help you focus when deriving a new gestureLayout from and old one. It also makes sure that what you set gets loaded in the way that you expect.
# The entries that are stripped out are everything that is not "value".
#
Expand All @@ -24,6 +24,6 @@ fi
fileName="$1"
temporaryFileName="$fileName.cleaned"

grep '\(:$\|^ *\(value: \|groups\)\)' "$fileName" > "$temporaryFileName"
grep -v '\(zzzEmpty\|oldValue\):' "$fileName" > "$temporaryFileName"
diff "$temporaryFileName" "$fileName"
mv "$temporaryFileName" "$fileName"

0 comments on commit 007937f

Please sign in to comment.