Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New hook: remove unicode quotes #6

Open
danielhoherd opened this issue Jul 14, 2021 · 0 comments
Open

New hook: remove unicode quotes #6

danielhoherd opened this issue Jul 14, 2021 · 0 comments

Comments

@danielhoherd
Copy link
Owner

Add a hook to replace unicode quotes with normal quotes. EG:

$ cat ~/code/dho-bin/fix-shitty-quotes.sh
#!/usr/bin/env bash
# shellcheck disable=SC1111
# Purpose: Remove unicode quotes from content.
# Caveats: This is just a dump search/replace. It does not account for quoted
#          content that will be misquoted after removing unicode quotes.

if [ "${#@}" -lt 1 ]; then
    echo "Replaces shitty quotes with normal quotes in all given files"
    echo "example: grep -rl '[“”’]' | xargs ${0##*/}"
    exit 1
fi

if [ "$(uname)" == 'Darwin' ]; then
    [ ! -e /usr/local/bin/gsed ] && {
        echo "GNU sed is required because bsd sed is lame."
        exit 1
    }
    /usr/local/bin/gsed -i 's/[“”]/"/g' "$@"
    /usr/local/bin/gsed -i "s/’/'/g" "$@"
else
    sed -i 's/[“”]/"/g' "$@"
    sed -i "s/’/'/g" "$@"
fi
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

No branches or pull requests

1 participant