summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2019-07-27 17:00:47 -0400
committerJune McEnroe <june@causal.agency>2019-07-27 17:00:47 -0400
commit76c6a9b42a3604d30911c96d5ce4ae3c9be4de97 (patch)
treea923f81ad039cdacc7b1e29153a5a27ae2d30868
parentAdd c11.pdf (diff)
downloadsrc-76c6a9b42a3604d30911c96d5ce4ae3c9be4de97.tar.gz
src-76c6a9b42a3604d30911c96d5ce4ae3c9be4de97.zip
Shell script style pass
-rw-r--r--bin/html.sh6
-rwxr-xr-xetc/tf/link.sh6
-rwxr-xr-xinstall.sh26
-rwxr-xr-xlink.sh24
-rwxr-xr-xprune.sh8
-rw-r--r--www/text.causal.agency/Makefile14
-rw-r--r--[-rwxr-xr-x]www/text.causal.agency/feed.sh39
7 files changed, 62 insertions, 61 deletions
diff --git a/bin/html.sh b/bin/html.sh
index cb7f1a66..924cb278 100644
--- a/bin/html.sh
+++ b/bin/html.sh
@@ -6,9 +6,9 @@ readonly GiteaURL='https://code.causal.agency/june/src/src/branch/master/bin'
 src=$1
 man=${2:-}
 
-./hi -f html -o document,tab=4 -n "${src}" /dev/null | sed '/<pre/d'
+./hi -f html -o document,tab=4 -n "$src" /dev/null | sed '/<pre/d'
 cat <<- EOF
 	<code><a href="${GiteaURL}/${src}">${src} in git</a></code>
 EOF
-[ -f "${man}" ] && man -P cat "${PWD}/${man}" | ./ttpre
-./hi -f html -o anchor "${src}"
+[ -f "$man" ] && man -P cat "${PWD}/${man}" | ./ttpre
+./hi -f html -o anchor "$src"
diff --git a/etc/tf/link.sh b/etc/tf/link.sh
index 2c75d075..03bd25e5 100755
--- a/etc/tf/link.sh
+++ b/etc/tf/link.sh
@@ -1,7 +1,7 @@
 #!/bin/sh
-set -e -u
+set -eu
 
-tf="$HOME/Library/Application Support/Steam/steamapps/common/Team Fortress 2/tf"
+tf="${HOME}/Library/Application Support/Steam/steamapps/common/Team Fortress 2/tf"
 for cfg in cfg/*.cfg; do
-	ln -s -f "$PWD/$cfg" "$tf/$cfg"
+	ln -fs "${PWD}/${cfg}" "${tf}/${cfg}"
 done
diff --git a/install.sh b/install.sh
index d970b363..2d34c373 100755
--- a/install.sh
+++ b/install.sh
@@ -15,25 +15,25 @@ Darwin() {
 	if [ ! -d /opt/pkg ]; then
 		tar="bootstrap-trunk-x86_64-${pkgsrcTag}.tar.gz"
 		url="https://pkgsrc.joyent.com/packages/Darwin/bootstrap/${tar}"
-		curl -O "${url}"
-		sudo tar -pxz -f "${tar}" -C /
-		rm "${tar}"
+		curl -O "$url"
+		sudo tar -pxz -f "$tar" -C /
+		rm "$tar"
 	fi
 	sudo pkgin update
-	sudo pkgin install ${pkgDarwin}
+	sudo pkgin install $pkgDarwin
 	sudo ln -fs /opt/pkg/bin/gpg2 /usr/local/bin/gpg
 	if [ ! -f /usr/local/bin/nvim ]; then
-		tar="nvim-macos.tar.gz"
-		base="https://github.com/neovim/neovim/releases/download"
+		tar='nvim-macos.tar.gz'
+		base='https://github.com/neovim/neovim/releases/download'
 		url="${base}/${neovimTag}/${tar}"
-		curl -L -O "${url}"
-		sudo tar -x -f "${tar}" -C /usr/local --strip-components 1
-		rm "${tar}"
+		curl -L -O "$url"
+		sudo tar -x -f "$tar" -C /usr/local --strip-components 1
+		rm "$tar"
 	fi
 }
 
 FreeBSD() {
-	pkg install ${pkgFreeBSD}
+	pkg install $pkgFreeBSD
 }
 
 NetBSD() {
@@ -41,15 +41,15 @@ NetBSD() {
 		base="ftp://ftp.NetBSD.org/pub/pkgsrc/packages"
 		export PKG_PATH="${base}/$(uname -s)/$(uname -p)/$(uname -r)/All"
 		pkg_add pkgin
-		echo "${PKG_PATH}" > /usr/pkg/etc/pkgin/repositories.conf
+		echo "$PKG_PATH" > /usr/pkg/etc/pkgin/repositories.conf
 	fi
 	pkgin update
-	pkgin install ${pkgNetBSD}
+	pkgin install $pkgNetBSD
 	ln -fs /usr/pkg/bin/gpg2 /usr/local/bin/gpg
 }
 
 Linux() {
-	pacman -Sy --needed ${pkgLinux}
+	pacman -Sy --needed $pkgLinux
 }
 
 $(uname)
diff --git a/link.sh b/link.sh
index 0f1f49aa..d74f4788 100755
--- a/link.sh
+++ b/link.sh
@@ -1,18 +1,18 @@
 #!/bin/sh
-set -e -u
+set -eu
 
 if [ $# -eq 1 ]; then
-	linkPath=$1
-	filePath="$PWD/home/${linkPath#$HOME/}"
-	[ ! -f "$filePath" ]
-	mkdir -p "$(dirname "$filePath")"
-	mv "$linkPath" "$filePath"
+	link=$1
+	file="${PWD}/home/${link#${HOME}/}"
+	[ ! -f "$file" ]
+	mkdir -p "${file%/*}"
+	mv "$link" "$file"
 fi
 
-find home -type f | while read -r findPath; do
-	filePath="$PWD/$findPath"
-	linkPath="$HOME/${findPath#home/}"
-	mkdir -p "$(dirname "$linkPath")"
-	[ \( -f "$linkPath" -a -L "$linkPath" \) -o ! -f "$linkPath" ]
-	ln -s -f "$filePath" "$linkPath"
+find home -type f | while read -r find; do
+	file="${PWD}/${find}"
+	link="${HOME}/${find#home/}"
+	mkdir -p "${link%/*}"
+	[ \( -f "$link" -a -L "$link" \) -o ! -f "$link" ]
+	ln -fs "$file" "$link"
 done
diff --git a/prune.sh b/prune.sh
index 31ab30cf..d41c6bc6 100755
--- a/prune.sh
+++ b/prune.sh
@@ -1,7 +1,7 @@
 #!/bin/sh
-set -e -u
+set -eu
 
-find -L ~ -type l -lname "$PWD/*" | while read -r linkPath; do
-	rm "$linkPath"
-	echo "$linkPath"
+find -L ~ -type l -lname "${PWD}/*" | while read -r link; do
+	echo "$link"
+	rm "$link"
 done
diff --git a/www/text.causal.agency/Makefile b/www/text.causal.agency/Makefile
index 8f2a55a1..09076305 100644
--- a/www/text.causal.agency/Makefile
+++ b/www/text.causal.agency/Makefile
@@ -6,18 +6,18 @@ TXTS += 003-pleasant-c.txt
 TXTS += 004-uloc.txt
 TXTS += 005-testing-c.txt
 
-all: $(TXTS)
+all: ${TXTS}
 
 .SUFFIXES: .7 .txt
 
 .7.txt:
-	mandoc $< | col -b -x > $@
+	mandoc $< | col -bx > $@
 
-feed.atom: $(TXTS)
-	./feed.sh > feed.atom
+feed.atom: feed.sh ${TXTS}
+	sh feed.sh > feed.atom
 
 clean:
-	rm -f $(TXTS) feed.atom
+	rm -f ${TXTS} feed.atom
 
-install: $(TXTS) feed.atom
-	install -p -m 644 $(TXTS) feed.atom $(WEBROOT)
+install: ${TXTS} feed.atom
+	install -p -m 644 ${TXTS} feed.atom ${WEBROOT}
diff --git a/www/text.causal.agency/feed.sh b/www/text.causal.agency/feed.sh
index 3c6e6589..21b1d4a3 100755..100644
--- a/www/text.causal.agency/feed.sh
+++ b/www/text.causal.agency/feed.sh
@@ -1,29 +1,30 @@
 #!/bin/sh
-set -e -u
+set -eu
 
 updated=$(date -u '+%FT%TZ')
-cat <<EOF
-<?xml version="1.0" encoding="utf-8"?>
-<feed xmlns="http://www.w3.org/2005/Atom">
-<title>Causal Agency</title>
-<author><name>June</name><email>june@causal.agency</email></author>
-<link href="https://text.causal.agency"/>
-<id>https://text.causal.agency/</id>
-<updated>${updated}</updated>
+cat <<- EOF
+	<?xml version="1.0" encoding="utf-8"?>
+	<feed xmlns="http://www.w3.org/2005/Atom">
+	<title>Causal Agency</title>
+	<author><name>June</name><email>june@causal.agency</email></author>
+	<link href="https://text.causal.agency"/>
+	<id>https://text.causal.agency/</id>
+	<updated>${updated}</updated>
 EOF
 for entry in *.7; do
 	url="https://text.causal.agency/${entry%.7}.txt"
 	title=$(grep '^\.Nm' "$entry" | cut -c 5-)
 	summary=$(grep '^\.Nd' "$entry" | cut -c 5-)
-	updated=$(date -j -u -f '%s' "$(stat -f '%m' "$entry")" '+%FT%TZ')
-	cat <<EOF
-	<entry>
-	<title>${title}</title>
-	<summary>${summary}</summary>
-	<link href="${url}"/>
-	<id>${url}</id>
-	<updated>${updated}</updated>
-	</entry>
-EOF
+	mtime=$(stat -f '%m' "$entry")
+	updated=$(date -ju -f '%s' "$mtime" '+%FT%TZ')
+	cat <<- EOF
+		<entry>
+		<title>${title}</title>
+		<summary>${summary}</summary>
+		<link href="${url}"/>
+		<id>${url}</id>
+		<updated>${updated}</updated>
+		</entry>
+	EOF
 done
 echo '</feed>'