* [PATCH] lib/term: Quote tr character ranges to prevent glob expansion
@ 2026-05-12 9:56 Laurent Vivier
2026-05-13 0:40 ` David Gibson
0 siblings, 1 reply; 2+ messages in thread
From: Laurent Vivier @ 2026-05-12 9:56 UTC (permalink / raw)
To: passt-dev; +Cc: Laurent Vivier
Single-letter files in the working directory cause glob expansion of
unquoted tr character ranges like [A-Z] and [a-z]. When the shell
expands these against matching filenames, tr receives wrong arguments
and pane_or_context_run() hangs without errors.
Apply the same fix as in a36031a4d807 ("seccomp.sh: Quote tr character
ranges to prevent glob expansion"): quote all tr ranges in test/lib/term.
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
---
test/lib/term | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/test/lib/term b/test/lib/term
index 89e4fdbe591d..2d2d2182de14 100755
--- a/test/lib/term
+++ b/test/lib/term
@@ -198,7 +198,7 @@ pane_run() {
# pane_wait() - Wait for command to be done in given pane name
# $1: Pane name
pane_wait() {
- __lc="$(echo "${1}" | tr [A-Z] [a-z])"
+ __lc="$(echo "${1}" | tr '[A-Z]' '[a-z]')"
sleep 0.01 || sleep 1
__done=0
@@ -213,7 +213,7 @@ pane_wait() {
# pane_parse() - Print last line, @EMPTY@ if command had no output
# $1: Pane name
pane_parse() {
- __pane_lc="$(echo "${1}" | tr [A-Z] [a-z])"
+ __pane_lc="$(echo "${1}" | tr '[A-Z]' '[a-z]')"
__buf="$(tail -n2 ${LOGDIR}/pane_${__pane_lc}.log | head -n1 | sed 's/^[^\r]*\r\([^\r]\)/\1/;s/^[[]][^^[]*^[[\]//g' | tr -d '\r\n')"
@@ -267,7 +267,7 @@ pane_or_context_run() {
# Redirect stdin to stop ssh from eating the test instructions file we have on stdin
context_run "${__name}" "$@" >/dev/null 2>&1 < /dev/null
else
- __uc="$(echo "${__name}" | tr [a-z] [A-Z])"
+ __uc="$(echo "${__name}" | tr '[a-z]' '[A-Z]')"
pane_run "${__uc}" "$@"
pane_status "${__uc}"
fi
@@ -283,7 +283,7 @@ pane_or_context_run_bg() {
# Redirect stdin to stop ssh from eating the test instructions file we have on stdin
context_run_bg "${__name}" "$@" >/dev/null 2>&1 < /dev/null
else
- __uc="$(echo "${__name}" | tr [a-z] [A-Z])"
+ __uc="$(echo "${__name}" | tr '[a-z]' '[A-Z]')"
pane_run "${__uc}" "$@"
fi
}
@@ -303,7 +303,7 @@ pane_or_context_output() {
echo "${__output}"
fi
else
- __uc="$(echo "${__name}" | tr [a-z] [A-Z])"
+ __uc="$(echo "${__name}" | tr '[a-z]' '[A-Z]')"
pane_run "${__uc}" "$@"
pane_wait "${__uc}"
pane_parse "${__uc}"
@@ -318,7 +318,7 @@ pane_or_context_wait() {
if context_exists "${__name}"; then
context_wait "${__name}"
else
- __uc="$(echo "${__name}" | tr [a-z] [A-Z])"
+ __uc="$(echo "${__name}" | tr '[a-z]' '[A-Z]')"
pane_wait "${__uc}"
fi
}
--
2.54.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] lib/term: Quote tr character ranges to prevent glob expansion
2026-05-12 9:56 [PATCH] lib/term: Quote tr character ranges to prevent glob expansion Laurent Vivier
@ 2026-05-13 0:40 ` David Gibson
0 siblings, 0 replies; 2+ messages in thread
From: David Gibson @ 2026-05-13 0:40 UTC (permalink / raw)
To: Laurent Vivier; +Cc: passt-dev
[-- Attachment #1: Type: text/plain, Size: 3033 bytes --]
On Tue, May 12, 2026 at 11:56:51AM +0200, Laurent Vivier wrote:
> Single-letter files in the working directory cause glob expansion of
> unquoted tr character ranges like [A-Z] and [a-z]. When the shell
> expands these against matching filenames, tr receives wrong arguments
> and pane_or_context_run() hangs without errors.
>
> Apply the same fix as in a36031a4d807 ("seccomp.sh: Quote tr character
> ranges to prevent glob expansion"): quote all tr ranges in test/lib/term.
>
> Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
> ---
> test/lib/term | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/test/lib/term b/test/lib/term
> index 89e4fdbe591d..2d2d2182de14 100755
> --- a/test/lib/term
> +++ b/test/lib/term
> @@ -198,7 +198,7 @@ pane_run() {
> # pane_wait() - Wait for command to be done in given pane name
> # $1: Pane name
> pane_wait() {
> - __lc="$(echo "${1}" | tr [A-Z] [a-z])"
> + __lc="$(echo "${1}" | tr '[A-Z]' '[a-z]')"
> sleep 0.01 || sleep 1
>
> __done=0
> @@ -213,7 +213,7 @@ pane_wait() {
> # pane_parse() - Print last line, @EMPTY@ if command had no output
> # $1: Pane name
> pane_parse() {
> - __pane_lc="$(echo "${1}" | tr [A-Z] [a-z])"
> + __pane_lc="$(echo "${1}" | tr '[A-Z]' '[a-z]')"
>
> __buf="$(tail -n2 ${LOGDIR}/pane_${__pane_lc}.log | head -n1 | sed 's/^[^\r]*\r\([^\r]\)/\1/;s/^[[]][^^[]*^[[\]//g' | tr -d '\r\n')"
>
> @@ -267,7 +267,7 @@ pane_or_context_run() {
> # Redirect stdin to stop ssh from eating the test instructions file we have on stdin
> context_run "${__name}" "$@" >/dev/null 2>&1 < /dev/null
> else
> - __uc="$(echo "${__name}" | tr [a-z] [A-Z])"
> + __uc="$(echo "${__name}" | tr '[a-z]' '[A-Z]')"
> pane_run "${__uc}" "$@"
> pane_status "${__uc}"
> fi
> @@ -283,7 +283,7 @@ pane_or_context_run_bg() {
> # Redirect stdin to stop ssh from eating the test instructions file we have on stdin
> context_run_bg "${__name}" "$@" >/dev/null 2>&1 < /dev/null
> else
> - __uc="$(echo "${__name}" | tr [a-z] [A-Z])"
> + __uc="$(echo "${__name}" | tr '[a-z]' '[A-Z]')"
> pane_run "${__uc}" "$@"
> fi
> }
> @@ -303,7 +303,7 @@ pane_or_context_output() {
> echo "${__output}"
> fi
> else
> - __uc="$(echo "${__name}" | tr [a-z] [A-Z])"
> + __uc="$(echo "${__name}" | tr '[a-z]' '[A-Z]')"
> pane_run "${__uc}" "$@"
> pane_wait "${__uc}"
> pane_parse "${__uc}"
> @@ -318,7 +318,7 @@ pane_or_context_wait() {
> if context_exists "${__name}"; then
> context_wait "${__name}"
> else
> - __uc="$(echo "${__name}" | tr [a-z] [A-Z])"
> + __uc="$(echo "${__name}" | tr '[a-z]' '[A-Z]')"
> pane_wait "${__uc}"
> fi
> }
> --
> 2.54.0
>
--
David Gibson (he or they) | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you, not the other way
| around.
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-05-13 0:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-05-12 9:56 [PATCH] lib/term: Quote tr character ranges to prevent glob expansion Laurent Vivier
2026-05-13 0:40 ` David Gibson
Code repositories for project(s) associated with this public inbox
https://passt.top/passt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).