Support cross-testing (version 3)
Roland McGrath
roland@hack.frob.com
Wed Oct 24 21:37:00 GMT 2012
> +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
More information about the Libc-alpha
mailing list