diff options
author | EuAndreh <eu@euandre.org> | 2024-11-14 00:21:09 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2024-11-14 00:21:09 -0300 |
commit | f2a9bee4af2a9cfc8865df91edbbcd5fe69ac36f (patch) | |
tree | dc3905470a30405c78a61286002664bdc62919ed /bin/shesc | |
parent | bin/forever: Add "-n" option, remove long options (diff) | |
download | dotfiles-f2a9bee4af2a9cfc8865df91edbbcd5fe69ac36f.tar.gz dotfiles-f2a9bee4af2a9cfc8865df91edbbcd5fe69ac36f.tar.xz |
Move bin/{htmlesc,shesc,uri} to eut
Diffstat (limited to 'bin/shesc')
-rwxr-xr-x | bin/shesc | 85 |
1 files changed, 0 insertions, 85 deletions
diff --git a/bin/shesc b/bin/shesc deleted file mode 100755 index b7a4a1b..0000000 --- a/bin/shesc +++ /dev/null @@ -1,85 +0,0 @@ -#!/bin/sh -set -eu - - -usage() { - cat <<-'EOF' - Usage: - shesc [CONTENT...] - shesc -h - EOF -} - -help() { - cat <<-'EOF' - - - Options: - -h, --help show this message - - CONTENT a literal string to be escaped - - - Convert data to/from POSIX sh double quote string escaping. If - CONTENT is not given, get data from STDIN. - - - Examples: - - Escape sh control characters in a string: - - $ printf 'content="%s"\n' "$(shesc '"string" $(dollar "`cmd`") \ ')" - content="\"string\" \$(dollar \"\`cmd\`\") \\ " - - - Escape the content from a file: - - $ shesc < file.conf - EOF -} - - -for flag in "$@"; do - case "$flag" in - (--) - break - ;; - (--help) - usage - help - exit - ;; - (*) - ;; - esac -done - -while getopts 'h' flag; do - case "$flag" in - (h) - usage - help - exit - ;; - (*) - usage >&2 - exit 2 - ;; - esac -done -shift $((OPTIND - 1)) - - - -esc() { - sed 's|\([\\`"$]\)|\\\1|g' -} - - -if [ $# = 0 ]; then - esc -else - for s in "$@"; do - printf '%s\n' "$s" | esc - done -fi |