Changeset View
Changeset View
Standalone View
Standalone View
bin/sh/t_here.sh
Property | Old Value | New Value |
---|---|---|
File Mode | 100755 | 100644 |
# $NetBSD: t_here.sh,v 1.6 2016/03/31 16:21:52 christos Exp $ | # $NetBSD: t_here.sh,v 1.7 2019/01/22 14:31:53 kre Exp $ | ||||
# | # | ||||
# Copyright (c) 2007 The NetBSD Foundation, Inc. | # Copyright (c) 2007 The NetBSD Foundation, Inc. | ||||
# All rights reserved. | # All rights reserved. | ||||
# | # | ||||
# Redistribution and use in source and binary forms, with or without | # Redistribution and use in source and binary forms, with or without | ||||
# modification, are permitted provided that the following conditions | # modification, are permitted provided that the following conditions | ||||
# are met: | # are met: | ||||
# 1. Redistributions of source code must retain the above copyright | # 1. Redistributions of source code must retain the above copyright | ||||
▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | if ! [ -s "${TEMP_FILE}" ]; then | ||||
echo >&2 \ | echo >&2 \ | ||||
"[$TEST_NUM] Expected messages on stderr, nothing produced" | "[$TEST_NUM] Expected messages on stderr, nothing produced" | ||||
fail=true | fail=true | ||||
fi | fi | ||||
fi | fi | ||||
rm -f "${TEMP_FILE}" | rm -f "${TEMP_FILE}" | ||||
# Remove newlines (use local shell for this) | # Remove newlines (use local shell for this) | ||||
oifs="$IFS" | result="$( | ||||
IFS="$nl" | IFS="$nl" | ||||
result="$(echo $result)" | set -f | ||||
IFS="$oifs" | set -- $result | ||||
IFS=' ' | |||||
printf %s "$*" | |||||
)" | |||||
if [ "$2" != "$result" ] | if [ "$2" != "$result" ] | ||||
then | then | ||||
echo >&2 "[$TEST_NUM] Expected output '$2', received '$result'" | echo >&2 "[$TEST_NUM] Expected output '$2', received '$result'" | ||||
fail=true | fail=true | ||||
fi | fi | ||||
if $fail | if $fail | ||||
then | then | ||||
▲ Show 20 Lines • Show All 374 Lines • ▼ Show 20 Lines | quoting_body() { | ||||
END | END | ||||
' "' \" \\" 0 | ' "' \" \\" 0 | ||||
check 'X=12345; Y="string1 line1?-line2"; Z=; unset W; cat <<-EOF | check 'X=12345; Y="string1 line1?-line2"; Z=; unset W; cat <<-EOF | ||||
${#X}${Z:-${Y}}${W+junk}${Y%%l*}${Y#*\?} | ${#X}${Z:-${Y}}${W+junk}${Y%%l*}${Y#*\?} | ||||
"$Z"'\''$W'\'' ${Y%" "*} $(( X + 54321 )) | "$Z"'\''$W'\'' ${Y%" "*} $(( X + 54321 )) | ||||
EOF | EOF | ||||
' '5string1 line1?-line2string1 -line2 ""'\'\'' string1 66666' 0 | ' '5string1 line1?-line2string1 -line2 ""'\'\'' string1 66666' 0 | ||||
# check that \ only quotes the magic chars, otherwise is retained | |||||
check 'p=A; cat <<-EOF | |||||
${p+\%$p\%} | |||||
${p+%$p%} | |||||
EOF | |||||
' '\%A\% %A%' 0 | |||||
# and check that " is not magic, so \ does not quote it | |||||
check 'p=A; cat <<-EOF | |||||
${p+\"$p\"} | |||||
${p+"$p"} | |||||
EOF | |||||
' '\"A\" "A"' 0 | |||||
# except in a ${var%<word>} word, base syntax reapplies, and | |||||
# there quotes are magic again | |||||
check 'p=ABCD; cat <<-EOF | |||||
${p%B?D} | |||||
${p%B\?D} | |||||
${p%"BCD"} | |||||
"${p%??}" | |||||
${p#"${p%??}"} | |||||
"${p#"${p%?"?"}"}" | |||||
EOF | |||||
' 'A ABCD A "AB" CD ""' 0 | |||||
check 'p=AB??; cat <<-EOF | |||||
${p%B?D} | |||||
${p%B\??} | |||||
${p%"B??"} | |||||
"${p%??}" | |||||
${p#"${p%??}"} | |||||
"${p#"${p%?"?"}"}" | |||||
EOF | |||||
' 'AB?? A A "AB" ?? "??"' 0 | |||||
results | results | ||||
} | } | ||||
atf_test_case side_effects | atf_test_case side_effects | ||||
side_effects_head() { | side_effects_head() { | ||||
atf_set "descr" "Tests how side effects in here documents are handled" | atf_set "descr" "Tests how side effects in here documents are handled" | ||||
} | } | ||||
▲ Show 20 Lines • Show All 83 Lines • Show Last 20 Lines |