1
0
Fork 0
mirror of https://github.com/notwa/rc synced 2024-05-18 09:53:22 -07:00

simplify character whitelist using built-in shell expansions

This commit is contained in:
Connor Olding 2021-10-07 10:57:31 -07:00
parent 7befe5065a
commit cfd3c2b18b

2
sh/oxo
View File

@ -65,7 +65,7 @@ oxo() { ### @-
local g="$f"
# restrict the filepath to simple ascii characters that curl likes.
if [ -n "$(printf '%s' "$f" | tr -d \''0-9A-Za-z !#$%&()*+,./;=@[]^_`{}~-')" ]; then
if [ "$f" != "${f#*[! -~]}" ] || [ "$f" != "${f#*[\":<>?\\|]}" ]; then
# copy the user's file to a temporary path and use that instead.
g=/tmp/oxo
#printf "$warn" "oxo: special characters found: $f" >&2