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

Re: git branch in Bash subshell "$(git branch -a)" including ls output as part of return?

From
AJAlex Jones <ajones@netsertive.com>
Date
Dec 7, 2015, 17:57 UTC
Message-ID
<CAJGk2Wx9cng8+9f0PxX1WFiGPLnoufMKgN8x0HWP-L0Xj8Nr-Q@mail.gmail.com>
In-Reply-To
<20151207170259.GA25915@hashpling.org>
That did the trick, thanks for the help and the suggestion.
On Mon, Dec 7, 2015 at 12:02 PM, Charles Bailey <charles@hashpling.org> wrote:
Show 13 quoted lines
> On Mon, Dec 07, 2015 at 04:58:10PM +0000, Charles Bailey wrote:
>>
>> Looking at the two outputs, you are seeing the shell's glob expansion of
>> the '*' current branch marker. You probably want to quote the command
>> expansion to prevent this:
>>
>> echo "$(git branch -a)"
>
> Pressing send has, of course, caused me to think further. You probably
> don't want to parse the output of a "porcelain" command such as "git
> branch" at all, but instead look at using something like "git
> for-each-ref", perhaps with the --format=%(refname) option, grepping out
> master and iterating through the rest.
-- 
Alex Jones | Software Engineer
919-238-4404 direct
336-263-2099 mobile
netsertive.com
Previous: Charles Bailey
Message 4 of 4 in “git branch in Bash subshell "$(git branch -a)" including ls output as part of return?”
  1. Alex JonesDec 7, 2015
  2. Charles BaileyDec 7, 2015
  3. Charles BaileyDec 7, 2015
  4. Alex JonesDec 7, 2015

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.