Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/packaging/postinstall_macos
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ autoload -Uz compinit
compinit
# <<< specs completion <<<
EOF
echo "Enabling auto-complete on this machine. Restarting the terminal many be required."
fi

exit 0
33 changes: 33 additions & 0 deletions .github/packaging/postuninstall_macos
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash
# Disable the zsh completion for specs that was enabled by postinstall_macos.
#
# This script is the counterpart of postinstall_macos. It is used by the local
# "make uninstall" target to undo the change postinstall_macos made to
# /etc/zshrc, so the behaviour stays symmetric with installation.
#
# It is idempotent: the sentinel-wrapped block is only removed when the markers
# are present, so running it any number of times never fails or touches an
# /etc/zshrc that we never modified.
set -e

ZSHRC="/etc/zshrc"
MARKER="# >>> specs completion >>>"
END_MARKER="# <<< specs completion <<<"

if grep -qF "$MARKER" "$ZSHRC" 2>/dev/null; then
tmp="$(mktemp)"
# Drop the sentinel-wrapped block as well as any blank line(s) that
# immediately precede it (postinstall_macos inserts one before the block).
awk -v start="$MARKER" -v end="$END_MARKER" '
$0 == start { blanks = ""; inblock = 1; next }
inblock { if ($0 == end) inblock = 0; next }
/^[[:space:]]*$/ { blanks = blanks $0 "\n"; next }
{ printf "%s", blanks; blanks = ""; print }
END { printf "%s", blanks }
' "$ZSHRC" > "$tmp"
cat "$tmp" > "$ZSHRC"
/bin/rm -f "$tmp"
echo "Disabling auto-complete on this machine"
fi

exit 0
22 changes: 19 additions & 3 deletions specs/src/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,22 @@ def python_search(arg):

install_win: $(EXE_DIR)/specs.exe
echo "Please copy the file specs.exe in the EXE dir to a location on the PATH"

uninstall_mac:
/bin/rm -f /usr/local/bin/specs
/bin/rm -f /usr/local/bin/specs-autocomplete
/bin/rm -f /usr/local/share/man/man1/specs.1.gz
/bin/rm -f /usr/local/share/zsh/site-functions/_specs
/bin/bash ../../.github/packaging/postuninstall_macos

uninstall_linux:
/bin/rm -f /usr/local/bin/specs
/bin/rm -f /usr/local/bin/specs-autocomplete
/bin/rm -f /usr/local/share/man/man1/specs.1.gz
/bin/rm -f /etc/bash_completion.d/specs

uninstall_win:
echo "Installation on Windows only copies specs.exe to the PATH; nothing to uninstall. Please manually remove specs.exe if desired."
"""

clear_clean_posix = \
Expand Down Expand Up @@ -816,10 +832,10 @@ def python_search(arg):
makefile.write("{}\n".format(clear_clean_part))

if sys.platform=="darwin":
makefile.write("{}\n\ninstall: install_mac\n".format(manpart))
makefile.write("{}\n\ninstall: install_mac\n\nuninstall: uninstall_mac\n".format(manpart))
elif platform=="NT":
makefile.write("install: install_win\n")
makefile.write("install: install_win\n\nuninstall: uninstall_win\n")
else:
makefile.write("{}\n\ninstall: install_linux\n".format(manpart))
makefile.write("{}\n\ninstall: install_linux\n\nuninstall: uninstall_linux\n".format(manpart))

sys.stderr.write("Makefile created.\n")