From 61a499daed9a29c5469eb6cbd058e8280c0bf6f7 Mon Sep 17 00:00:00 2001 From: Rafael Vuijk Date: Thu, 1 Oct 2026 23:25:02 +0000 Subject: [PATCH 1/2] The Terminal's .deb installs amcli, with a man page and completion The package's launcher, angourimath-terminal, ran the Terminal without its arguments, so the one-shot commands of #1654 could not be reached from the .deb, and the package had no amcli command at all. The launcher now has a shebang and passes "$@" on, and amcli is a link to it. The package also installs amcli.1 under /usr/share/man/man1 (#1658) and a bash completion script for the commands under /usr/share/bash-completion/completions (#1659). The script packs under umask 022, so that the package's modes do not depend on who packs it: under a stricter umask, dpkg-deb refused the control directory, and the installed files would have been unreadable to other users. Closes #1658, closes #1659, part of #1660. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura --- .github/workflows/TerminalNightly.yml | 2 + Sources/Terminal/AngouriMath.Terminal/amcli.1 | 79 +++++++++++++++++++ .../Terminal/AngouriMath.Terminal/amcli.bash | 9 +++ .../AngouriMath.Terminal/pack-deb-linux.sh | 13 ++- 4 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 Sources/Terminal/AngouriMath.Terminal/amcli.1 create mode 100644 Sources/Terminal/AngouriMath.Terminal/amcli.bash diff --git a/.github/workflows/TerminalNightly.yml b/.github/workflows/TerminalNightly.yml index ef5ec31d7..374d826eb 100644 --- a/.github/workflows/TerminalNightly.yml +++ b/.github/workflows/TerminalNightly.yml @@ -14,6 +14,8 @@ on: - '.github/workflows/TerminalNightly.yml' - 'Sources/Terminal/AngouriMath.Terminal/publish.sh' - 'Sources/Terminal/AngouriMath.Terminal/pack-deb-linux.sh' + - 'Sources/Terminal/AngouriMath.Terminal/amcli.1' + - 'Sources/Terminal/AngouriMath.Terminal/amcli.bash' workflow_dispatch: inputs: version: diff --git a/Sources/Terminal/AngouriMath.Terminal/amcli.1 b/Sources/Terminal/AngouriMath.Terminal/amcli.1 new file mode 100644 index 000000000..ba7db136b --- /dev/null +++ b/Sources/Terminal/AngouriMath.Terminal/amcli.1 @@ -0,0 +1,79 @@ +.TH AMCLI 1 "" "AngouriMath" "User Commands" +.SH NAME +amcli \- the AngouriMath terminal, and commands that answer once +.SH SYNOPSIS +.B amcli +.br +.B amcli +.I command +.RI [ argument ...] +.SH DESCRIPTION +With no arguments, +.B amcli +opens the AngouriMath terminal: an F# prompt with AngouriMath loaded. +.PP +With a command, +.B amcli +answers once and exits, without starting F#, so that it can sit in a pipe or a script. +An argument written as +.BR _ , +or left out, is read from standard input. +.SH COMMANDS +.TP +.BI eval " expr" +Evaluates +.I expr +to a number, a boolean, or a + bi. A rational is written as a decimal. +.TP +.BI simp " expr" +Simplifies +.IR expr . +.TP +.BI fsimp " expr" +Simplifies +.I expr +quickly: the normalisation, without the search. +.TP +.BI diff " var expr" +Differentiates +.I expr +over +.IR var . +.TP +.BI solve " var statement" +Solves +.I statement +over +.IR var , +one root per line when there are finitely many. +.TP +.BI sub " var value expr" +Substitutes +.I value +for +.I var +in +.IR expr . +.TP +.BI latex " expr" +Writes +.I expr +as LaTeX. +.TP +.B help +Lists the commands. +.SH EXIT STATUS +0 for an answer; 1 when the input does not parse or cannot be answered; 2 for a command that +does not exist or is missing an argument. +.SH EXAMPLES +.nf +$ amcli simp "sin(x)^2 + cos(x)^2" +1 +$ amcli solve x "x^2 \- 1 = 0" +1 +\-1 +$ echo "1 + x^2" | amcli diff x +2 * x +.fi +.SH SEE ALSO +https://am.angouri.org diff --git a/Sources/Terminal/AngouriMath.Terminal/amcli.bash b/Sources/Terminal/AngouriMath.Terminal/amcli.bash new file mode 100644 index 000000000..3ba6ea8bc --- /dev/null +++ b/Sources/Terminal/AngouriMath.Terminal/amcli.bash @@ -0,0 +1,9 @@ +# Bash completion for amcli, the AngouriMath terminal: the command after it. +_amcli() +{ + local current="${COMP_WORDS[COMP_CWORD]}" + if [ "$COMP_CWORD" -eq 1 ]; then + COMPREPLY=( $(compgen -W "eval simp fsimp diff solve sub latex help" -- "$current") ) + fi +} +complete -F _amcli amcli angourimath-terminal diff --git a/Sources/Terminal/AngouriMath.Terminal/pack-deb-linux.sh b/Sources/Terminal/AngouriMath.Terminal/pack-deb-linux.sh index e5f09a638..9a0e2723a 100755 --- a/Sources/Terminal/AngouriMath.Terminal/pack-deb-linux.sh +++ b/Sources/Terminal/AngouriMath.Terminal/pack-deb-linux.sh @@ -2,6 +2,9 @@ # The .deb's version is the release's: TerminalNightly.yml passes the packages' version, read # from the release's tag. version="${TERMINAL_VERSION:?set TERMINAL_VERSION to the version to pack, such as 2.6.0}" +# The package's modes come from the umask it is packed under: dpkg-deb refuses a control directory +# other users cannot read, and what it installs has to be readable by them too. +umask 022 cd publish-output for arch in amd64 arm arm64 @@ -27,8 +30,16 @@ do mkdir -p ./usr/share/applications/ cp -r ../$dotnet_arch ./usr/local/bin mv ./usr/local/bin/$dotnet_arch ./usr/local/bin/angourimath-terminal-data - echo 'cd /usr/local/bin/angourimath-terminal-data && ./AngouriMath.Terminal' > ./usr/local/bin/angourimath-terminal + # The arguments go through, so that `amcli simp "..."` answers once, and amcli is the same + # launcher under the name the dotnet tool has. + printf '#!/bin/sh\ncd /usr/local/bin/angourimath-terminal-data && exec ./AngouriMath.Terminal "$@"\n' > ./usr/local/bin/angourimath-terminal chmod +x ./usr/local/bin/angourimath-terminal + ln -s angourimath-terminal ./usr/local/bin/amcli + + mkdir -p ./usr/share/man/man1/ + gzip -9 -n -c ../../amcli.1 > ./usr/share/man/man1/amcli.1.gz + mkdir -p ./usr/share/bash-completion/completions/ + install -m 0644 ../../amcli.bash ./usr/share/bash-completion/completions/amcli mkdir DEBIAN && cd DEBIAN touch control From 885bf4f09194d281469f123821f02b3307753de0 Mon Sep 17 00:00:00 2001 From: Rafael Vuijk Date: Thu, 1 Oct 2026 23:47:20 +0000 Subject: [PATCH 2/2] The man page and the completion name amcli info #1661 merged, so info is one of amcli's commands now. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura --- Sources/Terminal/AngouriMath.Terminal/amcli.1 | 6 ++++++ Sources/Terminal/AngouriMath.Terminal/amcli.bash | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Sources/Terminal/AngouriMath.Terminal/amcli.1 b/Sources/Terminal/AngouriMath.Terminal/amcli.1 index ba7db136b..80955f7f7 100644 --- a/Sources/Terminal/AngouriMath.Terminal/amcli.1 +++ b/Sources/Terminal/AngouriMath.Terminal/amcli.1 @@ -60,6 +60,12 @@ Writes .I expr as LaTeX. .TP +.BI info " expr" +Describes +.IR expr : +its variables, the derivative and the roots over each, and its stationary points, each classified +by the second derivative test. +.TP .B help Lists the commands. .SH EXIT STATUS diff --git a/Sources/Terminal/AngouriMath.Terminal/amcli.bash b/Sources/Terminal/AngouriMath.Terminal/amcli.bash index 3ba6ea8bc..a909bd994 100644 --- a/Sources/Terminal/AngouriMath.Terminal/amcli.bash +++ b/Sources/Terminal/AngouriMath.Terminal/amcli.bash @@ -3,7 +3,7 @@ _amcli() { local current="${COMP_WORDS[COMP_CWORD]}" if [ "$COMP_CWORD" -eq 1 ]; then - COMPREPLY=( $(compgen -W "eval simp fsimp diff solve sub latex help" -- "$current") ) + COMPREPLY=( $(compgen -W "eval simp fsimp diff solve sub latex info help" -- "$current") ) fi } complete -F _amcli amcli angourimath-terminal