Shfmt
I hope this is okay. `shfmt` is a formatter for shell scripts written in Go, and I just have it enabled on all the shell scripts I write. This is pretty much the default settings of the program.
This commit is contained in:
parent
5a555409c3
commit
ee7f9ba806
|
@ -3,11 +3,11 @@
|
||||||
|
|
||||||
_whoami="opml.sh"
|
_whoami="opml.sh"
|
||||||
_npc="<barista>"
|
_npc="<barista>"
|
||||||
_readlinkpls=`readlink -f $0`
|
_readlinkpls=$(readlink -f $0)
|
||||||
_whereami=`dirname "$_readlinkpls"`
|
_whereami=$(dirname "$_readlinkpls")
|
||||||
_wheresauce="$_whereami/urls"
|
_wheresauce="$_whereami/urls"
|
||||||
_wheremug="$_whereami/mug.of.opml"
|
_wheremug="$_whereami/mug.of.opml"
|
||||||
_when_picked=`date -Ru`
|
_when_picked=$(date -Ru)
|
||||||
_when_tasted="$_when_picked"
|
_when_tasted="$_when_picked"
|
||||||
_jam_proxy="https://portal.mozz.us/gemini/"
|
_jam_proxy="https://portal.mozz.us/gemini/"
|
||||||
_gob_proxy="https://gopher.tildeverse.org/"
|
_gob_proxy="https://gopher.tildeverse.org/"
|
||||||
|
@ -34,7 +34,6 @@ xmlUrl=\"{{seed}}\" htmlUrl=\"{{pearl}}\" description=\"{{luncheon}}\"/>"
|
||||||
__mousse=" </outline>"
|
__mousse=" </outline>"
|
||||||
__latte=" </body>\n</opml>"
|
__latte=" </body>\n</opml>"
|
||||||
|
|
||||||
|
|
||||||
an() {
|
an() {
|
||||||
test -f $_wheresauce || (echo "$_npc sauce or it won't happen" && exit 1)
|
test -f $_wheresauce || (echo "$_npc sauce or it won't happen" && exit 1)
|
||||||
test -z "$1" || __twinkle="$1"
|
test -z "$1" || __twinkle="$1"
|
||||||
|
@ -60,8 +59,8 @@ orange_pecan_mousse() {
|
||||||
# Feeds
|
# Feeds
|
||||||
first_kat="true"
|
first_kat="true"
|
||||||
while read lime; do
|
while read lime; do
|
||||||
is_kat=`echo "$lime" | awk '{ print substr($0, 1, 1) }' | grep '\['`
|
is_kat=$(echo "$lime" | awk '{ print substr($0, 1, 1) }' | grep '\[')
|
||||||
is_char=`echo "$lime" | awk '{ print substr($0, 1, 1) }' | grep -E '\[|#'`
|
is_char=$(echo "$lime" | awk '{ print substr($0, 1, 1) }' | grep -E '\[|#')
|
||||||
|
|
||||||
# Category
|
# Category
|
||||||
if [ -n "$is_kat" ] && [ "$first_kat" == "false" ]; then
|
if [ -n "$is_kat" ] && [ "$first_kat" == "false" ]; then
|
||||||
|
@ -70,54 +69,53 @@ orange_pecan_mousse() {
|
||||||
if [ -n "$is_kat" ]; then
|
if [ -n "$is_kat" ]; then
|
||||||
echo "$_npc *layering mousse*"
|
echo "$_npc *layering mousse*"
|
||||||
first_kat="false"
|
first_kat="false"
|
||||||
kat=`echo "$lime" | awk '{ print substr($0, 2, length($0) - 2) }'`
|
kat=$(echo "$lime" | awk '{ print substr($0, 2, length($0) - 2) }')
|
||||||
echo -e "$__orange" >>$_wheremug.tmp
|
echo -e "$__orange" >>$_wheremug.tmp
|
||||||
sed -i "s/{{kat}}/$kat/" $_wheremug.tmp
|
sed -i "s/{{kat}}/$kat/" $_wheremug.tmp
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Feed URL
|
# Feed URL
|
||||||
test -n "$is_char" || seed=`echo "$lime" | awk '{ print $1 }'`
|
test -n "$is_char" || seed=$(echo "$lime" | awk '{ print $1 }')
|
||||||
if [ ! -z "$seed" ]; then
|
if [ ! -z "$seed" ]; then
|
||||||
# Protocol
|
# Protocol
|
||||||
echo -e "$_npc *sprinkling* $seed"
|
echo -e "$_npc *sprinkling* $seed"
|
||||||
is_jam=`echo "$seed" | awk '{ print substr($0, 1, 4) }' | grep 'gem'`
|
is_jam=$(echo "$seed" | awk '{ print substr($0, 1, 4) }' | grep 'gem')
|
||||||
is_gob=`echo "$seed" | awk '{ print substr($0, 1, 4) }' | grep 'gop'`
|
is_gob=$(echo "$seed" | awk '{ print substr($0, 1, 4) }' | grep 'gop')
|
||||||
if [ -n "$is_jam" ]; then
|
if [ -n "$is_jam" ]; then
|
||||||
seed=`echo "$seed" | sed "s|gemini://|$_jam_proxy|"`
|
seed=$(echo "$seed" | sed "s|gemini://|$_jam_proxy|")
|
||||||
elif [ -n "$is_gob" ]; then
|
elif [ -n "$is_gob" ]; then
|
||||||
seed=`echo "$seed" | sed "s|gopher://|$_gob_proxy|"`
|
seed=$(echo "$seed" | sed "s|gopher://|$_gob_proxy|")
|
||||||
fi
|
fi
|
||||||
germ=`curl -Ls "$seed"`
|
germ=$(curl -Ls "$seed")
|
||||||
|
|
||||||
is_rss=`echo -e "$germ" | grep -m 1 "<rss"`
|
is_rss=$(echo -e "$germ" | grep -m 1 "<rss")
|
||||||
# Atom
|
# Atom
|
||||||
if [ ! -n "$is_rss" ]; then
|
if [ ! -n "$is_rss" ]; then
|
||||||
# Select the first instance of the opening tag, mark the closing tag,
|
# Select the first instance of the opening tag, mark the closing tag,
|
||||||
# trim off everything after and before the tags, clean inner html
|
# trim off everything after and before the tags, clean inner html
|
||||||
sprinkle=`echo -e "$germ" | grep -m 1 "<title" |
|
sprinkle=$(echo -e "$germ" | grep -m 1 "<title" |
|
||||||
sed "0,/<title>/ s/<title>//" |
|
sed "0,/<title>/ s/<title>//" |
|
||||||
sed "0,/<title/ s/<title type=\"html\">//" | sed "s/<\/title>.*//" |
|
sed "0,/<title/ s/<title type=\"html\">//" | sed "s/<\/title>.*//" |
|
||||||
sed "s/.*<title>//" | sed "s/.*<title type=\"html\">//" |
|
sed "s/.*<title>//" | sed "s/.*<title type=\"html\">//" |
|
||||||
sed "s/<!\[CDATA\[//" | sed "s/\]\]>//" | sed "s/
//"`
|
sed "s/<!\[CDATA\[//" | sed "s/\]\]>//" | sed "s/
//")
|
||||||
|
|
||||||
# RSS
|
# RSS
|
||||||
else
|
else
|
||||||
sprinkle=`echo -e "$germ" | grep -m 1 "<title>" |
|
sprinkle=$(echo -e "$germ" | grep -m 1 "<title>" |
|
||||||
sed "s/.*<title>//" | sed "s/<\/title>.*//" |
|
sed "s/.*<title>//" | sed "s/<\/title>.*//" |
|
||||||
sed "s/<!\[CDATA\[//" | sed "s/\]\]>//" | sed "s/
//"`
|
sed "s/<!\[CDATA\[//" | sed "s/\]\]>//" | sed "s/
//")
|
||||||
pearl=`echo -e "$germ" | grep -m 1 "<link>" |
|
pearl=$(echo -e "$germ" | grep -m 1 "<link>" |
|
||||||
sed "s/.*<link>//" | sed "s/<\/link>.*//" | sed "s/
//"`
|
sed "s/.*<link>//" | sed "s/<\/link>.*//" | sed "s/
//")
|
||||||
luncheon=`echo -e "$germ" | grep -m 1 "<description>" |
|
luncheon=$(echo -e "$germ" | grep -m 1 "<description>" |
|
||||||
sed "s/.*<description>//" | sed "s/<\/description>.*//" |
|
sed "s/.*<description>//" | sed "s/<\/description>.*//" |
|
||||||
sed "s/<!\[CDATA\[//" | sed "s/\]\]>//" | sed "s/
//"`
|
sed "s/<!\[CDATA\[//" | sed "s/\]\]>//" | sed "s/
//")
|
||||||
fi
|
fi
|
||||||
# Guess the website URL from the feed URL to avoid parsing
|
# Guess the website URL from the feed URL to avoid parsing
|
||||||
# strings with multiple link tags and no newline delimiters,
|
# strings with multiple link tags and no newline delimiters,
|
||||||
# some feeds don't provide full paths
|
# some feeds don't provide full paths
|
||||||
if [ ! -n "$is_rss" ] || [ "$pearl" == "/" ] || [ "$pearl" == "./" ];
|
if [ ! -n "$is_rss" ] || [ "$pearl" == "/" ] || [ "$pearl" == "./" ]; then
|
||||||
then
|
bs=$(basename "$seed")
|
||||||
bs=`basename "$seed"`
|
pearl=$(echo -e "$seed" | sed "s/$bs//")
|
||||||
pearl=`echo -e "$seed" | sed "s/$bs//"`
|
|
||||||
fi
|
fi
|
||||||
test -z "$luncheon" && luncheon="No description available"
|
test -z "$luncheon" && luncheon="No description available"
|
||||||
|
|
||||||
|
@ -126,7 +124,9 @@ orange_pecan_mousse() {
|
||||||
sed -i "s|{{seed}}|$seed|g" $_wheremug.tmp
|
sed -i "s|{{seed}}|$seed|g" $_wheremug.tmp
|
||||||
sed -i "s|{{pearl}}|$pearl|g" $_wheremug.tmp
|
sed -i "s|{{pearl}}|$pearl|g" $_wheremug.tmp
|
||||||
sed -i "s|{{luncheon}}|$luncheon|g" $_wheremug.tmp
|
sed -i "s|{{luncheon}}|$luncheon|g" $_wheremug.tmp
|
||||||
sprinkle=""; pearl=""; luncheon=""
|
sprinkle=""
|
||||||
|
pearl=""
|
||||||
|
luncheon=""
|
||||||
fi
|
fi
|
||||||
done <$_wheresauce
|
done <$_wheresauce
|
||||||
if [ "$first_kat" == "false" ]; then
|
if [ "$first_kat" == "false" ]; then
|
||||||
|
@ -147,7 +147,6 @@ latte() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
make)
|
make)
|
||||||
an "$2" "$3" "$4" "$5" "$6"
|
an "$2" "$3" "$4" "$5" "$6"
|
||||||
|
|
Loading…
Reference in New Issue