Re: [PATCH 1/3] completion: fix alias listings with newlines

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Stephen Boyd schrieb:
>  __git_aliases ()
>  {
> -	local i IFS=$'\n'
> -	for i in $(git --git-dir="$(__gitdir)" config --get-regexp "alias\..*" 2>/dev/null); do
> -		i="${i#alias.}"
> -		echo "${i/ */}"
> +	local i
> +	git --git-dir="$(__gitdir)" config -z --get-regexp "alias\..*" 2>/dev/null |
> +	while IFS= read -rd '' i; do
> +		echo ${i#alias.} | cut -d' ' -f1
>  	done
>  }

Is it necessary to change the body of the loop? Your version spawns two
processes on each iteration, while the original spawned no processes.

You can avoid the pipeline (i.e. yet another process) using a "here-string":

	local i aliases=$(git --git-dir="$(__gitdir)" config -z \
				--get-regexp "alias\..*" 2>/dev/null)
	while IFS= read -rd '' i; do
		i="${i#alias.}"
		echo "${i/ */}"	# could be: echo "${i%% *}"
  	done <<< "$aliases"

but I don't know how well bash handles variable values with embedded NULs.

-- Hannes
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]