git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 4/8] bash: Add space after unique command name is completed.

From
Junio C Hamano <junkio@cox.net>
Date
Feb 4, 2007, 08:08 UTC
Message-ID
<7vr6t6xs3d.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<20070204073827.GD17603@spearce.org>
"Shawn O. Pearce" <spearce@spearce.org> writes:
Show 14 quoted lines
> +__gitcomp ()
> +{
> +	local all c s=$'\n' IFS=' '$'\t'$'\n'
> +	for c in $1; do
> +		case "$c" in
> +		--*=*) all="$all$c$s" ;;
> +		*)     all="$all$c $s" ;;
> +		esac
> +	done
> +	IFS=$s
> +	COMPREPLY=($(compgen -W "$all" -- "${COMP_WORDS[COMP_CWORD]}"))
> +	return
> +}
> +
I do not understand what is going on here.  Care to explain?
 (1) "for c in $1": because $1 is not dquoted, it is split into
     word with IFS -- which IFS applies to this splitting?  The
     local one you hand-define to the typical " \t\n" value?
 (2) when this function returns, what IFS value does the caller
     would have?  Is the "local" used to avoid screwing up the
     caller?
Previous: Shawn O. PearceNext: Shawn O. Pearce
Message 2 of 3 in “bash: Add space after unique command name is completed.”
  1. 4/8 bash: Add space after unique command name is completed.Shawn O. Pearce, Feb 4, 2007
  2. Junio C HamanoFeb 4, 2007
  3. Shawn O. PearceFeb 4, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.