export variables and use them in subprocesses

This commit is contained in:
2025-06-04 23:46:32 +02:00
parent 83061bd54b
commit 5144465792

View File

@@ -5,6 +5,8 @@ set -eu
err() { err() {
echo "$1" >/dev/tty echo "$1" >/dev/tty
} }
if [ -z "${FZF_VJOUR_USE_EXPORTED:-}" ]; then
# Read configuration # Read configuration
CONFIGFILE="$HOME/.config/fzf-vjour/config" CONFIGFILE="$HOME/.config/fzf-vjour/config"
if [ ! -f "$CONFIGFILE" ]; then if [ ! -f "$CONFIGFILE" ]; then
@@ -17,6 +19,9 @@ if [ -z "${ROOT:-}" ] || [ -z "${SYNC_CMD:-}" ] || [ -z "${COLLECTION_LABELS:-}"
err "Configuration is incomplete." err "Configuration is incomplete."
exit 1 exit 1
fi fi
export ROOT
export SYNC_CMD
export COLLECTION_LABELS
# Tools # Tools
if command -v "fzf" >/dev/null; then if command -v "fzf" >/dev/null; then
@@ -25,12 +30,16 @@ else
err "Did not find the command-line fuzzy finder fzf." err "Did not find the command-line fuzzy finder fzf."
exit 1 exit 1
fi fi
export FZF
if command -v "uuidgen" >/dev/null; then if command -v "uuidgen" >/dev/null; then
UUIDGEN="uuidgen" UUIDGEN="uuidgen"
else else
err "Did not find the uuidgen command." err "Did not find the uuidgen command."
exit 1 exit 1
fi fi
export UUIDGEN
if command -v "bat" >/dev/null; then if command -v "bat" >/dev/null; then
CAT="bat" CAT="bat"
elif command -v "batcat" >/dev/null; then elif command -v "batcat" >/dev/null; then
@@ -38,6 +47,7 @@ elif command -v "batcat" >/dev/null; then
fi fi
CAT=${CAT:+$CAT --color=always --style=numbers --language=md} CAT=${CAT:+$CAT --color=always --style=numbers --language=md}
CAT=${CAT:-cat} CAT=${CAT:-cat}
export CAT
### AWK SCRIPTS ### AWK SCRIPTS
AWK_ALTERTODO=$( AWK_ALTERTODO=$(
@@ -45,37 +55,46 @@ AWK_ALTERTODO=$(
@@include src/awk/altertodo.awk @@include src/awk/altertodo.awk
EOF EOF
) )
export AWK_ALTERTODO
AWK_EXPORT=$( AWK_EXPORT=$(
cat <<'EOF' cat <<'EOF'
@@include src/awk/export.awk @@include src/awk/export.awk
EOF EOF
) )
export AWK_EXPORT
AWK_GET=$( AWK_GET=$(
cat <<'EOF' cat <<'EOF'
@@include src/awk/get.awk @@include src/awk/get.awk
EOF EOF
) )
export AWK_GET
AWK_LIST=$( AWK_LIST=$(
cat <<'EOF' cat <<'EOF'
@@include src/awk/list.awk @@include src/awk/list.awk
EOF EOF
) )
export AWK_LIST
AWK_NEW=$( AWK_NEW=$(
cat <<'EOF' cat <<'EOF'
@@include src/awk/new.awk @@include src/awk/new.awk
EOF EOF
) )
export AWK_NEW
AWK_UPDATE=$( AWK_UPDATE=$(
cat <<'EOF' cat <<'EOF'
@@include src/awk/update.awk @@include src/awk/update.awk
EOF EOF
) )
export AWK_UPDATE
### END OF AWK SCRIPTS ### END OF AWK SCRIPTS
FZF_VJOUR_USE_EXPORTED="yes"
export FZF_VJOUR_USE_EXPORTED
fi
__lines() { __lines() {
find "$ROOT" -type f -name '*.ics' -print0 | xargs -0 -P 0 \ find "$ROOT" -type f -name '*.ics' -print0 | xargs -0 -P 0 \
@@ -133,7 +152,7 @@ if [ "${1:-}" = "--delete" ]; then
file=$(__filepath_from_selection "$2") file=$(__filepath_from_selection "$2")
summary=$(awk -v field="SUMMARY" "$AWK_GET" "$file") summary=$(awk -v field="SUMMARY" "$AWK_GET" "$file")
while true; do while true; do
printf "Do you want to delete the entry with the title \"%s\"? (yes/no)" "$summary" >/dev/tty printf "Do you want to delete the entry with the title \"%s\"? (yes/no): " "$summary" >/dev/tty
read -r yn read -r yn
case $yn in case $yn in
"yes") "yes")