This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: Support cross-testing (version 3)
- From: Roland McGrath <roland at hack dot frob dot com>
- To: "Joseph S. Myers" <joseph at codesourcery dot com>
- Cc: <libc-alpha at sourceware dot org>
- Date: Wed, 24 Oct 2012 14:37:18 -0700 (PDT)
- Subject: Re: Support cross-testing (version 3)
- References: <Pine.LNX.4.64.1210242035130.14661@digraph.polyomino.org.uk>
> +ssh='ssh'
> +while true; do
Use [ $# -gt 0 ].
> + case "$1" in
Indent with two spaces, not four (throughout).
> + "--ssh")
> + shift; ssh="$1"
Check for [ $# -gt 0 ] after shift (or -gt 1 before) and complain if not.
> +# Return all input as a properly quoted Bourne shell string.
> +bourne_quote ()
> +{
> + printf '%s' '"'
This is a bizarre way to write: printf '"'. And since this is always bash,
rather than some unknown POSIX.2 shell, you can just use echo -n and that
is more clear.
> + sed -n \
> + -e '1h' \
> + -e '2,$H' \
> + -e '${g
> + s/["$\`]/\\&/g
This omits numerous metacharacters.
The standard set is: [][#;\"*?&|<>(){}$`^]
> +blacklist_exports ()
> +{
> + local var
> + for var in ${env_blacklist}; do
> + unset $var
> + done
This can be just:
unset ${env_blacklist}
> +# Produce properly quoted Bourne shell arguments for 'env' to carry
> +# over the current environment, less blacklisted variables.
> +exports="$( (blacklist_exports) | sed -e 's|^declare -x |export |')"
$(...) always runs ... in a subshell, so the inner parens are superfluous.
The sed clause should just be in blacklist_exports.
> +# Transform the current argument list into a properly quoted Bourne shell
> +# command string.
> +command="$(for word in "$@"; do
> + printf '%s' "$word" | bourne_quote
> + printf '%s' ' '
Use echo -n.
> +full_command="$(printf '%s\n' "${command}" | bourne_quote | remove_newlines)"
Use plain echo.
Thanks,
Roland