Skip to content

Commit 1b3f001

Browse files
author
Matthias Koeppe
committed
sage-spkg-info, src/doc/bootstrap: Wrap command lines
1 parent 944e0d1 commit 1b3f001

File tree

3 files changed

+25
-11
lines changed

3 files changed

+25
-11
lines changed

build/bin/sage-print-system-package-command

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,16 @@ do
3434
;;
3535
--prompt)
3636
PROMPT=' $ '
37+
CONTINUATION=' '
38+
;;
39+
--continuation=*)
40+
CONTINUATION="${1#--continuation=}"
41+
;;
42+
--wrap)
43+
WRAP=78
44+
;;
45+
--wrap=*)
46+
WRAP="${1#--wrap=}"
3747
;;
3848
--no-install-recommends)
3949
NO_INSTALL_RECOMMENDS=yes
@@ -79,12 +89,16 @@ function print_shell_command()
7989
echo ".. CODE-BLOCK:: bash"
8090
echo
8191
fi
82-
echo -n "${PROMPT}"
83-
for a in "$@"; do
84-
# shell-quote arguments if necessary
85-
printf "%q " $a
86-
done
87-
echo
92+
# shell-quote arguments if necessary
93+
quoted=$(for a in "$@"; do printf "%q " $a; done)
94+
if [ -z "$WRAP" -o $# -lt 6 ]; then
95+
echo "${PROMPT}${quoted}"
96+
else
97+
if [ -z "$SAGE_BOOTSTRAP_PYTHON" ]; then
98+
SAGE_BOOTSTRAP_PYTHON=$(sage-bootstrap-python -c "import sys; print(sys.executable)")
99+
fi
100+
$SAGE_BOOTSTRAP_PYTHON -c "import textwrap; print(' \\\\\n'.join(textwrap.wrap(r'''${quoted}''', $WRAP, initial_indent=r'''${PROMPT}''', subsequent_indent=r'''${CONTINUATION}''', break_long_words=False, break_on_hyphens=False)))"
101+
fi
88102
if [ -n "$OUTPUT_RST" ]; then
89103
echo
90104
fi

build/bin/sage-spkg-info

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ for system in $systems; do
103103
echo "$system:"
104104
;;
105105
esac
106-
sage-print-system-package-command $system --prompt=' $ ' --sudo install $system_packages
106+
sage-print-system-package-command $system --wrap --prompt=' $ ' --continuation=' ' --sudo install $system_packages
107107
echo
108108
done
109109
if [ -z "$system" ]; then

src/doc/bootstrap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@ for SYSTEM in arch debian fedora homebrew opensuse; do
7474
if [ "${BOOTSTRAP_QUIET}" = "no" ]; then
7575
echo >&2 $0:$LINENO: installing "$OUTPUT_DIR"/$SYSTEM"*.txt"
7676
fi
77-
echo "$(sage-print-system-package-command $SYSTEM --prompt --sudo install $(echo $(echo $SYSTEM_PACKAGES | xargs -n 1 echo | sort | uniq)))" > "$OUTPUT_DIR"/$SYSTEM.txt
78-
echo "$(sage-print-system-package-command $SYSTEM --prompt --sudo install $(echo $(echo $OPTIONAL_SYSTEM_PACKAGES | xargs -n 1 echo | sort | uniq)))" > "$OUTPUT_DIR"/$SYSTEM-optional.txt
79-
echo "$(sage-print-system-package-command $SYSTEM --prompt --sudo install $(echo $(echo $RECOMMENDED_SYSTEM_PACKAGES | xargs -n 1 echo | sort | uniq)))" > "$OUTPUT_DIR"/$SYSTEM-recommended.txt
80-
echo "$(sage-print-system-package-command $SYSTEM --prompt --sudo install $(echo $(echo $DEVELOP_SYSTEM_PACKAGES | xargs -n 1 echo | sort | uniq)))" > "$OUTPUT_DIR"/$SYSTEM-develop.txt
77+
echo "$(sage-print-system-package-command $SYSTEM --prompt --wrap=84 --sudo install $(echo $(echo $SYSTEM_PACKAGES | xargs -n 1 echo | sort | uniq)))" > "$OUTPUT_DIR"/$SYSTEM.txt
78+
echo "$(sage-print-system-package-command $SYSTEM --prompt --wrap=84 --sudo install $(echo $(echo $OPTIONAL_SYSTEM_PACKAGES | xargs -n 1 echo | sort | uniq)))" > "$OUTPUT_DIR"/$SYSTEM-optional.txt
79+
echo "$(sage-print-system-package-command $SYSTEM --prompt --wrap=84 --sudo install $(echo $(echo $RECOMMENDED_SYSTEM_PACKAGES | xargs -n 1 echo | sort | uniq)))" > "$OUTPUT_DIR"/$SYSTEM-recommended.txt
80+
echo "$(sage-print-system-package-command $SYSTEM --prompt --wrap=84 --sudo install $(echo $(echo $DEVELOP_SYSTEM_PACKAGES | xargs -n 1 echo | sort | uniq)))" > "$OUTPUT_DIR"/$SYSTEM-develop.txt
8181
done
8282

8383
OUTPUT_DIR="src/doc/en/reference/spkg"

0 commit comments

Comments
 (0)