Skip to content

Commit a90f3ac

Browse files
author
Matthias Koeppe
committed
build/bin/sage-print-system-package-command: Shell-quote the packages
1 parent a0246a5 commit a90f3ac

File tree

1 file changed

+22
-17
lines changed

1 file changed

+22
-17
lines changed

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

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,12 @@ function print_shell_command()
7979
echo ".. CODE-BLOCK:: bash"
8080
echo
8181
fi
82-
echo "${PROMPT}$1"
82+
echo -n "${PROMPT}"
83+
for a in "$@"; do
84+
# shell-quote arguments if necessary
85+
printf "%q " $a
86+
done
87+
echo
8388
if [ -n "$OUTPUT_RST" ]; then
8489
echo
8590
fi
@@ -109,70 +114,70 @@ case $system:$command in
109114
# Verbs handled above are our own inventions. Verbs handled below are apt-get verbs.
110115
#
111116
@(debian*|ubuntu*):update)
112-
print_shell_command "${SUDO}apt-get $command $system_packages"
117+
print_shell_command ${SUDO}apt-get $command $system_packages
113118
;;
114119
@(debian*|ubuntu*):*)
115120
[ "$NO_INSTALL_RECOMMENDS" = yes ] && options="$options --no-install-recommends"
116121
[ "$YES" = yes ] && options="$options --yes" env="DEBIAN_FRONTEND=noninteractive "
117-
[ -n "$system_packages" ] && print_shell_command "${SUDO}${env}apt-get $command $options $system_packages"
122+
[ -n "$system_packages" ] && print_shell_command ${SUDO}${env}apt-get $command $options $system_packages
118123
;;
119124
@(fedora*|redhat*|centos*):install)
120125
[ "$YES" = yes ] && options="$options -y"
121-
[ -n "$system_packages" ] && print_shell_command "${SUDO}yum install $options $system_packages"
126+
[ -n "$system_packages" ] && print_shell_command ${SUDO}yum install $options $system_packages
122127
;;
123128
gentoo*:install)
124-
[ -n "$system_packages" ] && print_shell_command "${SUDO}emerge $system_packages"
129+
[ -n "$system_packages" ] && print_shell_command ${SUDO}emerge $system_packages
125130
;;
126131
arch*:update)
127132
print_shell_command "${SUDO}pacman -Sy"
128133
;;
129134
arch*:install)
130135
[ "$YES" = yes ] && options="$options --noconfirm"
131-
[ -n "$system_packages" ] && print_shell_command "${SUDO}pacman -S $options $system_packages"
136+
[ -n "$system_packages" ] && print_shell_command ${SUDO}pacman -S $options $system_packages
132137
;;
133138
void*:update)
134139
print_shell_command "${SUDO}xbps-install -Su"
135140
;;
136141
void*:install)
137142
[ "$YES" = yes ] && options="$options --yes"
138-
[ -n "$system_packages" ] && print_shell_command "${SUDO}xbps-install $options $system_packages"
143+
[ -n "$system_packages" ] && print_shell_command ${SUDO}xbps-install $options $system_packages
139144
;;
140145
opensuse*:install)
141-
[ -n "$system_packages" ] && print_shell_command "${SUDO}zypper install $system_packages"
146+
[ -n "$system_packages" ] && print_shell_command ${SUDO}zypper install $system_packages
142147
;;
143148
*conda*:install)
144149
[ "$YES" = yes ] && options="$options --yes"
145-
[ -n "$system_packages" ] && print_shell_command "conda install $options $system_packages"
150+
[ -n "$system_packages" ] && print_shell_command conda install $options $system_packages
146151
;;
147152
homebrew*:install)
148-
[ -n "$system_packages" ] && print_shell_command "brew install $system_packages"
153+
[ -n "$system_packages" ] && print_shell_command brew install $system_packages
149154
;;
150155
slackware*:install)
151-
[ -n "$system_packages" ] && print_shell_command "${SUDO}slackpkg install $system_packages"
156+
[ -n "$system_packages" ] && print_shell_command ${SUDO}slackpkg install $system_packages
152157
;;
153158
cygwin*:update)
154159
print_comment "first install apt-cyg from https://github.com/transcode-open/apt-cyg"
155160
;;
156161
cygwin*:install)
157-
[ -n "$system_packages" ] && print_shell_command "apt-cyg install $system_packages"
162+
[ -n "$system_packages" ] && print_shell_command apt-cyg install $system_packages
158163
;;
159164
freebsd*:install)
160-
[ -n "$system_packages" ] && print_shell_command "${SUDO}pkg install $system_packages"
165+
[ -n "$system_packages" ] && print_shell_command ${SUDO}pkg install $system_packages
161166
;;
162167
nix*:install)
163-
[ -n "$system_packages" ] && print_shell_command "nix-env --install $system_packages"
168+
[ -n "$system_packages" ] && print_shell_command nix-env --install $system_packages
164169
;;
165170
alpine:update)
166171
print_shell_command "apk update"
167172
;;
168173
alpine:install)
169-
[ -n "$system_packages" ] && print_shell_command "apk add $system_packages"
174+
[ -n "$system_packages" ] && print_shell_command apk add $system_packages
170175
;;
171176
pip:install)
172-
[ -n "$system_packages" ] && print_shell_command "sage -pip install $system_packages"
177+
[ -n "$system_packages" ] && print_shell_command sage -pip install $system_packages
173178
;;
174179
cpan:install)
175-
[ -n "$system_packages" ] && print_shell_command "cpan -i $system_packages"
180+
[ -n "$system_packages" ] && print_shell_command cpan -i $system_packages
176181
;;
177182
repology:install)
178183
if [ -n "$system_packages" ]; then

0 commit comments

Comments
 (0)