diff options
author | Benjamin Chausse <benjamin@chausse.xyz> | 2024-08-09 14:11:50 -0400 |
---|---|---|
committer | Benjamin Chausse <benjamin@chausse.xyz> | 2024-08-09 14:11:50 -0400 |
commit | 5857d82e8e596d6fda406a0c4d8d68ca7a03c124 (patch) | |
tree | 553916894dee907825360580c5d9a05c82c5af16 /sfeed_opml_export | |
parent | 3574e3cbf9d99546e868aeb995ce2c171cdc36a6 (diff) | |
parent | 19957bc272e745af7b56b79fa648e8b6b77113b1 (diff) |
Diffstat (limited to 'sfeed_opml_export')
-rwxr-xr-x | sfeed_opml_export | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/sfeed_opml_export b/sfeed_opml_export index eb22520..f949488 100755 --- a/sfeed_opml_export +++ b/sfeed_opml_export @@ -7,19 +7,19 @@ loadconfig() { if [ "$1" != "" ]; then # get absolute path of config file required for including. config="$1" - path=$(readlink -f "${config}" 2>/dev/null) + configpath=$(readlink -f "${config}" 2>/dev/null) else # default config location. config="$HOME/.sfeed/sfeedrc" - path="${config}" + configpath="${config}" fi # config is loaded here to be able to override $sfeedpath or functions. - if [ -r "${path}" ]; then - . "${path}" + if [ -r "${configpath}" ] && [ -f "${configpath}" ]; then + . "${configpath}" else - echo "Configuration file \"${config}\" cannot be read." >&2 - echo "See sfeedrc.example for an example." >&2 + printf "Configuration file \"%s\" cannot be read.\n" "${config}" >&2 + echo "See the sfeedrc.example file or the sfeedrc(5) man page for an example." >&2 exit 1 fi } @@ -27,8 +27,8 @@ loadconfig() { # override feed function to output OPML XML. # feed(name, feedurl, [basesiteurl], [encoding]) feed() { - # TABs, newlines and echo options in field values are not checked. - echo "$1 $2" + # uses the characters 0x1f and 0x1e as a separator. + printf '%s\037%s\036' "$1" "$2" } # load config file. @@ -38,12 +38,16 @@ cat <<! <?xml version="1.0" encoding="UTF-8"?> <opml version="1.0"> <head> - <title>OPML export from sfeed</title> + <title>OPML export</title> </head> <body> ! -feeds | awk -F '\t' '{ +feeds | LC_ALL=C awk ' +BEGIN { + FS = "\x1f"; RS = "\x1e"; +} +{ gsub("&", "\\&"); gsub("\"", "\\""); gsub("'"'"'", "\\'"); |