commit - a66c62baa08d6819aa08016da1cd3c16e8731153
commit + 7922604282e94f2a59c63a949370a71226b6a65c
blob - 8e6951a25e5b7dbccff68a068d7417ae364a20aa
blob + b083565b34b11e1397e042fb1acb901d28e5bbe3
--- notify-replace
+++ notify-replace
-#!/bin/sh
+#!/bin/sh -u
# Sends, remembers, and replaces notifications based on program name that's
# passed as first argument to script. Uses notify-send.
# Non-POSIX features used: flock(1)
# TODO: consider replacing flock(1) with a POSIX-complaint alternative
-xdg_config_home="${XDG_CONFIG_HOME:-$HOME/.config}"
-config_dir="$xdg_config_home/notify-replace"
+config_dir="${XDG_CONFIG_HOME:-$HOME/.config}/notify-replace"
[ -d "$config_dir" ] || mkdir -p "$config_dir"
-if [ -z "$1" ]; then
+if [ -z "${1:-}" ]; then
# TODO: check if there's a better way to acquire name of currently
# executing script
# TODO: get rid of subshell
- program=$(basename $0)
- # TODO: shorten line
- echo "$program: Need to provide notification id filename as first argument" 1>&2
+ echo "$(basenme "$0"): Need to provide notification id filename as first \
+ argument" 1>&2
exit 1
fi
-lockdir="$config_dir/notify-replace.lock"
-notification_file="$config_dir/$1"
+lockdir="${config_dir}/notify-replace.lock"
+notification_file="${config_dir}/${1}"
shift
# Exit if lock is in use. A lock is used to prevent multiple invocations