aboutsummaryrefslogtreecommitdiffstats
path: root/lib-src
diff options
context:
space:
mode:
authorPaul Eggert2015-10-10 18:03:49 -0700
committerPaul Eggert2015-10-10 18:11:27 -0700
commit29dfca23553b9995a8ec3b50090a652a6a0ecb01 (patch)
treea5d968df7cadd8259e029d89e6150dfe6762cb96 /lib-src
parentec0d4d24fd11b5040de9f7657b486c3b1e743071 (diff)
downloademacs-29dfca23553b9995a8ec3b50090a652a6a0ecb01.tar.gz
emacs-29dfca23553b9995a8ec3b50090a652a6a0ecb01.zip
Use ‘echo’ safely with ‘\’ or leading ‘-’
POSIX says that ‘echo FOO’ produces implementation-defined output if FOO contains leading ‘-’, or ‘\’ anywhere, so don’t assume GNU behavior in that case. * Makefile.in (removenullpaths): Remove. (epaths-force): Rewrite to avoid the need for ‘echo’. (install-etc): Be clearer about escaping the shell metacharacters ‘\’ and ‘$’. * Makefile.in (install-arch-indep, install-etcdoc): * admin/charsets/mapconv, admin/merge-gnulib, admin/merge-pkg-config: * admin/quick-install-emacs, build-aux/gitlog-to-emacslog: * configure.ac, lib-src/rcs2log, make-dist: * src/Makefile.in (lisp.mk): Don’t assume ‘echo’ outputs ‘\’ and leading ‘-’ unscathed. For example, use ‘printf '%s\n' "$foo"’ rather than ‘echo "$foo"’ if $foo can contain arbitrary characters. * lisp/Makefile.in (TAGS): Use ‘ls’, not ‘echo’, to avoid ‘\’ issues. * doc/lispref/two-volume.make (vol1.pdf): * test/etags/make-src/Makefile (web ftp publish): Use ‘printf’ rather than ‘echo -e’.
Diffstat (limited to 'lib-src')
-rwxr-xr-xlib-src/rcs2log20
1 files changed, 11 insertions, 9 deletions
diff --git a/lib-src/rcs2log b/lib-src/rcs2log
index d1bd3693183..4ee303d03a1 100755
--- a/lib-src/rcs2log
+++ b/lib-src/rcs2log
@@ -130,7 +130,8 @@ do
130 case $1 in 130 case $1 in
131 -n) case ${2?}${3?}${4?} in 131 -n) case ${2?}${3?}${4?} in
132 *"$tab"* | *"$nl"*) 132 *"$tab"* | *"$nl"*)
133 echo >&2 "$0: -n '$2' '$3' '$4': tabs, newlines not allowed" 133 printf '%s\n' >&2 \
134 "$0: -n '$2' '$3' '$4': tabs, newlines not allowed"
134 exit 1;; 135 exit 1;;
135 esac 136 esac
136 login=$2 137 login=$2
@@ -140,7 +141,7 @@ do
140 # If $2 is not tab-separated, use colon for separator. 141 # If $2 is not tab-separated, use colon for separator.
141 case ${2?} in 142 case ${2?} in
142 *"$nl"*) 143 *"$nl"*)
143 echo >&2 "$0: -u '$2': newlines not allowed" 144 printf '%s\n' >&2 "$0: -u '$2': newlines not allowed"
144 exit 1;; 145 exit 1;;
145 *"$tab"*) 146 *"$tab"*)
146 t=$tab;; 147 t=$tab;;
@@ -149,7 +150,7 @@ do
149 esac 150 esac
150 case $2 in 151 case $2 in
151 *"$t"*"$t"*"$t"*) 152 *"$t"*"$t"*"$t"*)
152 echo >&2 "$0: -u '$2': too many fields" 153 printf '%s\n' >&2 "$0: -u '$2': too many fields"
153 exit 1;; 154 exit 1;;
154 *"$t"*"$t"*) 155 *"$t"*"$t"*)
155 uf="[^$t]*$t" # An unselected field, followed by a separator. 156 uf="[^$t]*$t" # An unselected field, followed by a separator.
@@ -161,7 +162,7 @@ do
161 expr "X$2" : "$uf$uf$sf" 162 expr "X$2" : "$uf$uf$sf"
162 `;; 163 `;;
163 *) 164 *)
164 echo >&2 "$0: -u '$2': not enough fields" 165 printf '%s\n' >&2 "$0: -u '$2': not enough fields"
165 exit 1;; 166 exit 1;;
166 esac 167 esac
167 shift;; 168 shift;;
@@ -186,9 +187,9 @@ do
186 --version) 187 --version)
187 set $Id 188 set $Id
188 rcs2logVersion=$3 189 rcs2logVersion=$3
189 echo >&2 "rcs2log (GNU Emacs) $rcs2logVersion$nl$Copyright" 190 printf '%s\n' >&2 "rcs2log (GNU Emacs) $rcs2logVersion$nl$Copyright"
190 exit 0;; 191 exit 0;;
191 -*) echo >&2 "Usage: $0 [OPTION]... [FILE ...]$nl$Help" 192 -*) printf '%s\n' >&2 "Usage: $0 [OPTION]... [FILE ...]$nl$Help"
192 case $1 in 193 case $1 in
193 --help) exit 0;; 194 --help) exit 0;;
194 *) exit 1;; 195 *) exit 1;;
@@ -303,7 +304,8 @@ case $rlogfile in
303 esac 304 esac
304 if test ! -d "$repository" 305 if test ! -d "$repository"
305 then 306 then
306 echo >&2 "$0: $repository: bad repository (see CVS/Repository)" 307 printf '%s\n' >&2 \
308 "$0: $repository: bad repository (see CVS/Repository)"
307 exit 1 309 exit 1
308 fi 310 fi
309 pository=$repository;; 311 pository=$repository;;
@@ -330,7 +332,7 @@ case $rlogfile in
330 T?*) 332 T?*)
331 rlog_options=-r`expr "$CVSTAG" : 'T\(.*\)'`;; 333 rlog_options=-r`expr "$CVSTAG" : 'T\(.*\)'`;;
332 *) 334 *)
333 echo >&2 "$0: invalid CVS/Tag"; exit 1;; 335 printf '%s\n' >&2 "$0: invalid CVS/Tag"; exit 1;;
334 esac 336 esac
335 fi;; 337 fi;;
336 esac 338 esac
@@ -595,7 +597,7 @@ case $hostname in
595 hostname=`( 597 hostname=`(
596 hostname || uname -n || uuname -l || cat /etc/whoami 598 hostname || uname -n || uuname -l || cat /etc/whoami
597 ) 2>/dev/null` || { 599 ) 2>/dev/null` || {
598 echo >&2 "$0: cannot deduce hostname" 600 printf '%s\n' >&2 "$0: cannot deduce hostname"
599 exit 1 601 exit 1
600 } 602 }
601 603