Browse Source

remove obsolete awk escaping - related to PR 60562

master
Stefan Bodewig 8 years ago
parent
commit
af4eb228ec
1 changed files with 4 additions and 40 deletions
  1. +4
    -40
      src/script/ant

+ 4
- 40
src/script/ant View File

@@ -22,17 +22,6 @@ use_jikes_default=false
ant_exec_debug=false
show_help=false

esc_tool=sed

# if awk esc_tool is chosen, use nawk when available
if [ "$esc_tool" = "awk" ]
then
awk_exec=awk
# Solaris_awk does not support gsub, but Solaris_nawk does
# `command -v` behavior is part of posix spec
command -v nawk >/dev/null && awk_exec=nawk
fi

for arg in "$@" ; do
if [ "$arg" = "--noconfig" ] ; then
no_config=true
@@ -52,35 +41,10 @@ for arg in "$@" ; do
# use printf to avoid echo interpretation behaviors such as escapes and line continuation
# pad the value with X to protect leading/trailing whitespace from subshell output trimming
esc_arg="X${arg}X"
case "$esc_tool" in
'sed')
# Mac bsd_sed does not support group-0, so pattern uses group-1
# Solaris sed only proceses lines with trailing newline, passing in an extra newline
# subshell assignment will trim the added trailing newline
esc_arg="$(printf '%s\n' "$esc_arg" | sed -e 's@\([$"\\`]\)@\\\1@g')"
;;
'awk')
esc_arg="$(printf '%s' "$esc_arg" | "$awk_exec" '{ gsub(/\\/, "\\\\"); print }' )"
esc_arg="$(printf '%s' "$esc_arg" | "$awk_exec" '{ gsub(/\$/, "\\$"); print }' )"
esc_arg="$(printf '%s' "$esc_arg" | "$awk_exec" '{ gsub(/\"/, "\\\""); print }' )"
esc_arg="$(printf '%s' "$esc_arg" | "$awk_exec" '{ gsub(/`/, "\\`"); print }' )"
;;
# 'bash')
# # does not depend upon `sed` or `echo` quirks
# # tested with bash `[ -n "${BASH_VERSION}" ]`
# # tested with zsh `[ -n "${ZSH_NAME}" ]`
# # tested with ksh93+ `ksh_ver="$(echo "$KSH_VERSION" | grep -m 1 -o '[0-9]\+' | head -n 1)"; [ "$ksh_ver" -gt 88 ]`
# # fails in ksh88, dash, ash
# esc_arg="${esc_arg//\\/\\\\}" # must be first since later patterns introduce backslash chars
# esc_arg="${esc_arg//\$/\\\$}"
# esc_arg="${esc_arg//\"/\\\"}"
# esc_arg="${esc_arg//\`/\\\`}"
# ;;
'*')
echo "could not determine escaping tool"
exit 1
;;
esac
# Mac bsd_sed does not support group-0, so pattern uses group-1
# Solaris sed only proceses lines with trailing newline, passing in an extra newline
# subshell assignment will trim the added trailing newline
esc_arg="$(printf '%s\n' "$esc_arg" | sed -e 's@\([$"\\`]\)@\\\1@g')"
# remove the padding Xs added above
esc_arg="${esc_arg#X}"
esc_arg="${esc_arg%X}"


Loading…
Cancel
Save