Project

General

Profile

« Previous | Next » 

Revision 10890

bugfix: lib/sh/util.sh: set_fds(): need to escape redirect destinations which are files, because they may contain special shell characters

View differences:

lib/sh/util.sh
629 629
	local redirs=() i
630 630
	for i in "$@"; do
631 631
		local redir_prefix="$(match_prefix '*[<>]' "$i")"
632
		local dest="$(        rm_prefix    '*[<>]' "$i")"
633
		if ! starts_with '&' "$dest"; then # escape dest
634
			i="$redir_prefix$(printf %q "$dest")"
635
		fi
632 636
		if test "$redir_prefix"; then redirs+=("$redir_prefix&-"); fi
633 637
		# remove empty redirects resulting from using `redirs= cmd...` to clear
634 638
		# the redirs and then using $redirs as an array

Also available in: Unified diff